mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2771] [Issue]: Provider/model switch keeps stale fields; API key carried across a provider switch #1408
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#1408
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 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2771
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The provider/model-switch handlers in ConnectionEditor reset some fields but leave others stale, producing wrong context budgets, wrong auth, or stale output caps after a switch.
Sub-bug 1: Provider switch keeps stale maxContext (new-bug / missed-instance of #2660)
(a) The provider-button onClick clears model and resets
maxTokensOverride, but only re-seedslocalMaxContextfor the xai branch. Switching from a large-window model to a smaller provider, then typing a model id in the manual input (which bypassesselectModel), saves the old maxContext. Server-sideresolveModelAccessPolicycaps it down for KNOWN models, so impact is limited to UNKNOWN/custom models where the stale window disables trimming -> over-budget request / provider 400.(c) ConnectionEditor.tsx:884-904 (xai-only re-seed at 895-897), compare selectModel 709-716; manual input 1304-1307/1406-1418. Kind: missed-instance (low/medium).
Sub-bug 2: Stale API key across provider switch (new-bug)
(a) On load the key field is blanked (masked). The provider switch clears the key only for claude_subscription/openai_chatgpt; for any other key-based provider it leaves the field blank, so handleSave omits apiKey and the server keeps the OLD provider's encrypted key under the new provider -> 401 on first generation (e.g. an OpenAI
sk-key sent as Anthropic x-api-key). The key is masked/encrypted, so no leak — a misleading-state/wrong-request bug, self-correcting once a new key is typed.(c) ConnectionEditor.tsx:221 (blank on load), 884-904 (clears key only for 2 providers at 900-902), 412-415 (apiKey omitted when blank); connections.storage.ts:114-204 (only writes apiKeyEncrypted when provided, no provider-change revalidation). Kind: new-bug (medium).
Sub-bug 3: Stale remote maxOutput override after manual model change (new-bug)
(a)
selectModelwritesmodel.maxOutputinto the hardmaxTokensOverridefor remote models; the manual model-id input only setslocalModel, so the override stays pinned to the previous model's cap (serverMath.min), silently capping the new model's output. Field is visible/editable -> low.(c) ConnectionEditor.tsx:709-716, 1407-1419; server applyProviderMaxTokensOverride generation-parameters.ts:15-17. Kind: new-bug (low).
Suggested Fix
localMaxContext(seed from MODEL_LISTS[key][0]?.context or a conservative default), mirroring the maxTokensOverride reset.localApiKey(and surface a 'enter a new key for this provider' hint).maxTokensOverridewhen the model changes via the manual text input (or treat maxOutput as a soft hint).Template
pnpm checkpassesAffected files
packages/client/src/components/connections/ConnectionEditor.tsxpackages/server/src/services/storage/connections.storage.tsAudit provenance
Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged
stagingtree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: MEDIUM.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in PR #2747.\n\nWhat changed:\n- Provider switches now reset maxContext from the new provider's first known model, or the app default when there is no known model.\n- Provider switches clear the visible API key field and mark the stored encrypted key to be cleared on the next save, unless the user types a replacement key.\n- Clicking the already-selected provider no longer resets fields.\n- Manual model ID edits now clear stale maxTokensOverride values, while selecting a known/fetched model still applies its context/output hints.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.