mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2662] [Issue]: Generation-parameter salvage path forwards out-of-range sampler values unclamped #1313
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1313
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2662
Originally assigned to: @SpicyMarinara on GitHub.
Summary
When stored generation parameters fail schema validation on one field, the salvage path copies the remaining sampler values checking only
Number.isFinite, bypassing the schema's min/max bounds — so out-of-range values (e.g.temperature: 7,topP: 5) flow through to the provider request unclamped.Expected behavior
Salvaged parameters should be subject to the same per-field bounds as the canonical parse path; an out-of-range value should be rejected or clamped, not forwarded to the model.
Actual behavior
generationParametersSchema.partial().safeParsefailing on one malformed field triggers a salvage branch that copies temperature/topP/topK/minP/maxTokens/maxContext/frequencyPenalty/presencePenalty using onlytypeof value === "number" && Number.isFinite(value), without the schema bounds. Those values are then merged and sent to the provider.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/routes/generate/generate-route-utils.ts:819–833— copies scalars with only a finiteness check.packages/shared/src/schemas/prompt.schema.ts):temperature min(0).max(2),topP gt(0).max(1),maxTokens int().min(1), penaltiesmin(-2).max(2).applyParameterOverrides(generate.routes.ts:3263–3286) and out to the provider body unclamped (e.g.openai.provider.ts:867setsbody.temperaturewith no clamp).connections.storage.tsupdateDefaultParameters) does not validate against the schema, so such a blob can be persisted in the first place.Steps to reproduce
defaultParametersJSON containingtemperature: 7plus one field that fails schema validation (forcing the salvage branch).temperature: 7is merged in and sent to the model (provider 400 or degenerate output), with no indication the stored value was invalid.Suggested fix
In the salvage branch, run each scalar through the same per-field schema (or explicit clamps) used by the canonical path before accepting it, instead of only
Number.isFinite. Consider validating on the write path (updateDefaultParameters) as well so an invalid blob cannot be persisted.Environment
b826f8f4)Additional context
Identified via systematic source review on staging (refs @
b826f8f4). Edge-triggered (requires a partially-malformed stored blob) but results in unvalidated sampler values reaching the model. Related to thetop_p = 0handling issue filed concurrently.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 20, 2026):
Implemented on branch codex/spicymarinara-assigned-issues: salvaged stored generation parameters now pass per-field schema bounds, and default-parameter saves validate before persisting. Final validation will run after the full assigned sweep per maintainer request.