Skip to content

fix(sandbox): return 409 instead of 500 for a blocked rebase - #5134

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/rebase-blocked-error-409-w8
Jul 23, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/rebase-blocked-error-409-w8

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Source: bug found while auditing packages/sandbox/daemon/routes/git.ts for 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 via PublishBlockedError → 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 plain Error, which makeGitRebaseHandler fell through to a generic 500. A sandbox sitting on main and hitting "sync with base" got an opaque server-error toast instead of the same clear conflict message publish gets.

Fix: added RebaseBlockedError in rebase-onto-base.ts (mirrors PublishBlockedError), thrown for the detached-HEAD and protected-branch cases, and mapped to 409 in makeGitRebaseHandler. 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.ts and bun test packages/sandbox/daemon/git/rebase-onto-base.test.ts.

Checks run locally: bun run fmt, bunx tsc --noEmit in packages/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/rebase with publish() behavior.

  • Bug Fixes
    • Added RebaseBlockedError in packages/sandbox/daemon/git/rebase-onto-base.ts for detached HEAD and protected-branch checks.
    • Mapped RebaseBlockedError to 409 in makeGitRebaseHandler for the /git/rebase route.
    • Added a regression test to assert 409 on protected-branch refusal.

Written for commit c9fac51. Summary will update on new commits.

Review in cubic

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
pedrofrxncx enabled auto-merge (squash) July 23, 2026 20:39
@pedrofrxncx
pedrofrxncx merged commit 5cd4cda into main Jul 23, 2026
15 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/rebase-blocked-error-409-w8 branch July 23, 2026 20:43
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant