Repository navigation
fix(sandbox): return 409 instead of 500 for a blocked rebase - #5134
Merged
Merged
Conversation
rebaseOntoBase() refuses on a detached HEAD or a protected branch, but both threw a plain Error that the /git/rebase route mapped to a generic 500 — the same client/data conditions that publish() already maps to 409 via PublishBlockedError. Add the matching RebaseBlockedError so the rebase route reports the same conflict semantics.
pedrofrxncx
enabled auto-merge (squash)
July 23, 2026 20:39
decocms Bot
pushed a commit
that referenced
this pull request
Jul 23, 2026
PR: #5134 fix(sandbox): return 409 instead of 500 for a blocked rebase Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.22.0 -> 1.22.1 - deploy/helm/sandbox-env (chart 0.9.19) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.22.1 Deploy-Scope: both
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: bug found while auditing
packages/sandbox/daemon/routes/git.tsfor error-propagation gaps in the sandbox git rebase flow.Payoff:
publish()already distinguishes a client/data conflict (detached HEAD, protected branch) from a real server fault viaPublishBlockedError→ 409, so the UI can show a clear "can't publish from here" message instead of a generic error.rebaseOntoBase()has the exact same two guards (detached HEAD, protected branch — it's even more destructive since it force-pushes) but threw a plainError, whichmakeGitRebaseHandlerfell through to a generic 500. A sandbox sitting onmainand hitting "sync with base" got an opaque server-error toast instead of the same clear conflict message publish gets.Fix: added
RebaseBlockedErrorinrebase-onto-base.ts(mirrorsPublishBlockedError), thrown for the detached-HEAD and protected-branch cases, and mapped to 409 inmakeGitRebaseHandler. Added a regression test (rebase route returns 409 (not 500) for a protected-branch refusal) mirroring the existing publish-route test of the same shape.Verify:
bun test packages/sandbox/daemon/routes/git.test.tsandbun test packages/sandbox/daemon/git/rebase-onto-base.test.ts.Checks run locally:
bun run fmt,bunx tsc --noEmitinpackages/sandbox, and the two targeted test files above (32 + 2 tests, all green). Full CI validates the rest.Summary by cubic
Return 409 (Conflict) instead of 500 when a rebase is blocked by a detached HEAD or a protected branch, so the UI shows a clear “can’t rebase from here” message. Aligns
/git/rebasewithpublish()behavior.RebaseBlockedErrorinpackages/sandbox/daemon/git/rebase-onto-base.tsfor detached HEAD and protected-branch checks.RebaseBlockedErrorto 409 inmakeGitRebaseHandlerfor the/git/rebaseroute.Written for commit c9fac51. Summary will update on new commits.