mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1129] [Issue]: Deleting a connection leaves agents pointing at the dead ID, then silently runs them on the chat's connection #560
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#560
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 @etherious1804 on GitHub (May 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1129
Originally assigned to: @cha1latte on GitHub.
Summary
DELETE /api/connections/:idremoves a connection without checking or updating agent/chat records that reference it. Agents whoseconnectionIdbecomes dangling then silently fall back to the chat's connection at runtime, which can route paid-API traffic to a connection the user thought they had migrated away from.Expected behavior
Either:
409 Conflictand return the list of referencing agents/chats so the user can repoint them first (preferred — explicit user intent), orconnectionIds and surfacing a clear warning that those agents now use the chat connection.In addition, at generation time, an agent whose
connectionIdno longer resolves should emit a visible warning (the existingAgentConnectionWarningchannel already exists for related cases —local_sidecar_unavailable,default_agent_connection_active).Actual behavior
DELETE /api/connections/:idsucceeds with204regardless of how many agents reference it (packages/server/src/routes/connections.routes.ts:222-225).resolveAgentConnectionId(...)happily returns the dangling ID (packages/server/src/routes/generate/agent-connection-guards.ts:17-27— it doesn't validate existence).packages/server/src/routes/generate.routes.ts:3120-3144looks up the connection withconnections.getWithKey(effectiveConnectionId). When that returnsnullfor a dangling ID, theif (agentConn) { ... }block is skipped silently.agentProvider/agentModelkeep the chat connection's values that were initialized just above, so the agent transparently runs on the chat's connection — including its API key, model, and rate-limit profile.User-visible symptom: agents start failing with errors like
OpenAI API error 429: Provider returned errorfrom a provider the user thought they had stopped using. No warning, no log line tying the failure to a missing connection ID.Steps to reproduce
local(OAI-compatible/local model) anddefault(OpenRouter or any rate-limited paid API).default.defaultconnection from Settings → Connections (orcurl -X DELETE /api/connections/:id).local. Verify in the network/storage layer that the change actually persisted toagentConfigs.connectionId— in my case it did not, leaving the dangling reference.kimmi/OpenRouter). No warning is shown. If the chat connection is rate-limited, you get[agent-pipeline] Group REJECTED in phase "post_processing": [...] err: OpenAI API error 429.Confirmed locally on my install by inspecting the agents via the API: 20 agents all had
connectionId: "1QqiMpyBCCaRVd4Scjm30";GET /api/connections/1QqiMpyBCCaRVd4Scjm30returns{"error":"Connection not found"}.Environment
Notes for a fix
Two layers should change together:
Connection delete (
packages/server/src/routes/connections.routes.ts:222): before removing, count references inagentConfigs.connectionId(and the equivalent default-agent-connection setting if applicable). If> 0, return409with the list of referencing agent names/IDs. Accept?force=trueto override; on force, null out the references and emit a warning in the response. This mirrors typical FK ON-DELETE-RESTRICT semantics.Runtime resolution (
packages/server/src/routes/generate.routes.tsaround line 3120): whenconnections.getWithKey(effectiveConnectionId)returns null, add anAgentConnectionWarning(new code, e.g.dangling_agent_connection) toagentConnectionWarningsand either skip the agent or fall back explicitly to the chat connection — but never silently. The user must see that the configured connection no longer exists.Happy to put up a PR for the above approach if it sounds right.
@cha1latte commented on GitHub (May 25, 2026):
Closed in #1206