mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2772] [Issue]: Connection & agent transfer/import — dangling/stale connection ids and hijacked routing flags (isDefault/defaultForAgents) #1412
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#1412
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/2772
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Connection import/export and agent connection-override handling carry machine-local routing state across transfers and never reconcile deleted/invalid connection ids, producing hijacked defaults, dangling references, and silently re-saved dead ids.
Sub-bug 1: Import hijacks isDefault/defaultForAgents/useForRandom onto a keyless import (new-bug)
(a) Export emits these routing flags; import passes them through verbatim while forcing apiKey:'' .
storage.createhonorsisDefault(unsets all other defaults) anddefaultForAgents, so re-importing your default connection silently demotes your real key-bearing default and points global/agent default at a keyless connection -> next generation/agent 401s.(c) connection-transfer.ts:106-108/142-146; ImportConnectionModal.tsx:47; connections.storage.ts:55-80. Kind: new-bug (high).
Sub-bug 2: Import carries promptPresetId/embeddingConnectionId (missed-instance)
(a) These machine-local relational ids survive transfer; on another machine they dangle, so the connection appears to have a preset but generation falls back (warn), and embeddings point at a missing connection.
(c) connection-transfer.ts:113/119/140/149; stored with no FK validation. Kind: missed-instance (low).
Sub-bug 3: Deleting active chat's connection leaves dangling chat.connectionId (new-bug)
(a) Row/bulk delete only invalidates the connections list; it never clears the chat's connectionId. The main generate path then can't resolve the dead id and returns HTTP 400 'API connection not found' (no default fallback) until the user reassigns.
(c) ConnectionsPanel.tsx:667/852/1065; use-connections.ts:98-104; connections.routes.ts:311-314; generate.routes.ts:1281-1302. Kind: new-bug (medium).
Sub-bug 4-6: AgentEditor stale/invalid connection-override ids (new-bug/missed-instance)
(a) Image override (Illustrator/Tracker/Background) loads
imageConnectionIdwith no validation; a deleted id has no matching so the select shows 'None' while state keeps the dead id, and Save re-persists it -> server throws a hard agent error. Text override has the identical pattern (re-saves dead id; runtime safely skips). On lite builds a hidden__local_sidecar__id is re-saved while the UI shows 'Use chat connection'.(c) AgentEditor.tsx:516/822/937 (image), 507/902 (text), 1733 (lite sidecar gate). Kind: missed-instance/new-bug.
Sub-bug 7-10: duplicate/import edge cases
useForRandom(forces isDefault/defaultForAgents false but not this), silently doubling a pool member's selection weight (connections.storage.ts:222) — low/ux.maxParallelJobsuses unboundedasPositiveInteger; >16 fails the server.max(16)and, because the file loop shares one try, discards every other entry in the file (connection-transfer.ts:121/226-230; ImportConnectionModal.tsx:43-71) — low/validation.scrubSecretsrecurses into usercustomParametersand deletes keys named secret/password/authorization/etc., dropping legitimate request params on round-trip (connection-transfer.ts:171-200) — low/new-bug.Suggested Fix
isDefault:false, defaultForAgents:false, useForRandom:false, promptPresetId:null, embeddingConnectionId:null(machine-local routing/relational state must not transfer).__local_sidecar__away on lite builds).maxParallelJobsto MAX_PARALLEL_JOBS; wrap each import entry in its own try/catch (per-entry accounting; roll back or save defaults before marking imported).useForRandom:false. Limit secret scrubbing to top-level auth fields, not nested customParameters.Template
pnpm checkpassesAffected files
packages/client/src/lib/connection-transfer.tspackages/client/src/components/modals/ImportConnectionModal.tsxpackages/client/src/components/agents/AgentEditor.tsxpackages/client/src/hooks/use-connections.tspackages/server/src/services/storage/connections.storage.tspackages/server/src/routes/connections.routes.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: HIGH.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in PR #2747.\n\nWhat changed:\n- Connection imports now force machine-local routing/relationship fields to safe values: isDefault/defaultForAgents/useForRandom false, promptPresetId and embeddingConnectionId null.\n- Imported maxParallelJobs is clamped to the server-supported maximum.\n- Connection import processes entries independently, reports skipped entries, and rolls back a newly-created connection if saving its defaultParameters fails.\n- Connection defaultParameters export/import no longer recursively strips nested customParameters keys named like secrets; only top-level secret-ish fields are scrubbed.\n- Duplicated connections no longer copy useForRandom.\n- Deleting the active chat's assigned connection clears that chat's connectionId and updates/invalidate chat cache.\n- AgentEditor normalizes stale text/image connection override IDs on hydrate and save, including clearing the hidden local-sidecar ID on lite builds.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.