mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2962] [Issue]: Branching with an unknown cutoff message id silently copies the entire chat #1538
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#1538
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 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2962
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The "branch up to here" cutoff is just a loop break on a matching message id, with no check that the id actually exists. If a non-existent id is supplied, the cutoff never fires and the entire chat is copied, with no error.
How to reproduce (try it yourself)
Deterministic (raw API):
POST /chats/<id>/branchwith body{ "upToMessageId": "does-not-exist" }.You'll see: a
200with a full-length branch (the whole conversation copied), no error.Expected: a
400/404, or the branch stops at the requested message.(In the UI this is hard to hit — the branch button lives on the very message you'd branch at — so the realistic trigger is the raw API path, or a rare delete-races-branch window.)
Where it is
packages/server/src/routes/chats.routes.ts— the branch route destructuresupToMessageIdat line 2977 and uses it only as a loop break at 3062-3063 (if (upToMessageId && msg.id === upToMessageId) break;), with no presence validation before the copy loop (3024-3064). The copy happens before the break each iteration, so an unmatched id degrades to "copy everything."What's happening
There's no
msgs.some(m => m.id === upToMessageId)guard, so an unknown id silently means "no cutoff" rather than failing fast.Suggested fix
When
upToMessageIdis provided, verify it exists inmsgsbefore the loop and return400/404if not. Alternatively compute the slice index up front and iterate only that prefix, so an unknown id is detected explicitly.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in staging: branch creation now validates upToMessageId before creating anything and returns 404 when the cutoff message is not in the source chat. Validated with pnpm check and pnpm regression:prompt.