mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3865] Deleting a connection leaves dangling references across chat metadata and agent settings #2089
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#2089
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 @kh0p on GitHub (Jul 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3865
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Deleting a connection (
DELETE /api/connections/:id) removes only the connection row itself. Every stored reference to that id elsewhere is left untouched:chats.connectionId,agentConfigs.connectionId,connections.embeddingConnectionId, and the large family of*ConnectionIdkeys stored insidechats.metadata(illustratorPromptConnectionId,gameImageConnectionId,gameSceneConnectionId,sceneVideoConnectionId,imageGenConnectionId,agentOverrides.<type>.imageConnectionId, and others).Expected behavior
Deleting a connection should clear (null out) every stored reference to it, so no feature is left pointing at an id that no longer resolves to anything.
Actual behavior
References survive the delete. What happens next depends on which code path reads the dangling id:
services/generation/illustrator-prompt-runtime.ts(resolveIllustratorPromptRuntime, used by Gallery "Generate Selfie" and the Conversation/selfiecommand) throws synchronously when the id doesn't resolve — surfaced as a 400 to the caller, so at least fails fast.chatMetadata.illustratorPromptConnectionId(e.g. theagentType === "illustrator"special case inagent-resolution.ts/ its near-duplicate inretry-agents-route.ts) do not fail fast in practice. Reproduced firsthand: a chat with a staleillustratorPromptConnectionIdhad one post-processing agent turn silently route through an unrelated, much larger local model instead of the intended (or default-for-agents) connection, taking over an hour instead of the usual ~3 minutes for that turn. Clearing the stale metadata field immediately fixed it; re-introducing the same stale id reproduced the multi-minute misroute again.Steps to reproduce
illustratorPromptConnectionIdorgameImageConnectionId(no dedicated UI control for these two currently exists; they're set viaPATCH /api/chats/:id/metadata, but any chat that went through a setup wizard step touching these fields at the time can end up with one).GET /api/chats/:idstill shows the stale ids inconnectionIdandmetadata.Suggested fix
Sweep and null out every stored reference to a connection's id at delete time, in
connections.storage.ts'sremove(). Given how many distinct*ConnectionIdfields exist (15+ across chat metadata alone, per a repo-wide grep) and that new ones get added as features grow, a generic sweep — treat any JSON key matching/ConnectionId$/insidechats.metadataandagentConfigs.settings, at any nesting depth, as a reference and null it if it matches — seems more durable than hardcoding the current field list. Direct columns (chats.connectionId,agentConfigs.connectionId,connections.embeddingConnectionId) should be cleared the same way.I have a working patch for this (generic recursive sweep, verified end-to-end against a running install with a connection referenced four different ways including a nested
agentOverrides.<type>.imageConnectionId) and will open a PR againststaging.Environment