Repository navigation
fix(sandbox): return 400 instead of 500 when the rebase base branch isn't on origin - #5144
Merged
Merged
Conversation
…sn't on origin rebaseOntoBase() threw a plain Error when the requested base branch didn't exist on origin, which the /git/rebase route mapped to a generic 500 — the same client/data condition that computeDiffAgainstBase already maps to 400 via BaseBranchNotFoundError. Add a matching RebaseBaseBranchNotFoundError so the rebase route reports the same 400 semantics. This also fixes a latent bug in the fetch itself: `git fetch origin <base> <branch>` fails the whole command if `base` doesn't exist on origin, which skipped fetching `branch` (needed for the force-push lease) and threw a raw fetch error before the base-branch check ever ran. Fetching base and branch as separate requests fixes both.
pedrofrxncx
enabled auto-merge (squash)
July 23, 2026 22:30
decocms Bot
pushed a commit
that referenced
this pull request
Jul 23, 2026
PR: #5144 fix(sandbox): return 400 instead of 500 when the rebase base branch isn't on origin Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.22.2 -> 1.22.3 - deploy/helm/sandbox-env (chart 0.9.21) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.22.3 Deploy-Scope: both
This was referenced Jul 24, 2026
Merged
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.
Follows #5142 and #5134's hardening of the sandbox git routes' error-status mapping.
rebaseOntoBase()threw a plainErrorwhen the requested base branch didn't exist on origin (typo, deleted branch), which/git/rebasemapped to a generic 500 — the exact client/data condition thatcomputeDiffAgainstBasealready maps to 400 viaBaseBranchNotFoundError(#5142), and the same class of "conflict with current state, not a server fault" thatRebaseBlockedErroralready gets a 409 for on this same route (#5134). Added a matchingRebaseBaseBranchNotFoundError, mapped to 400 inmakeGitRebaseHandler.While reproducing this I found the check was actually unreachable in the common case:
git fetch -p origin <base> <branch>fails the whole fetch ifbasedoesn't exist on origin, so the code threw a raw fetch error (128, "couldn't find remote ref") before ever reaching theBaseBranchNotFoundErrorcheck below it — and skipped fetchingbranch, which the force-push lease relies on. Fetching base and branch as separate requests fixes both: a missing base no longer blocks fetching the branch, and the existing post-fetch check now actually runs and throws the typed error.Failure scenario: client calls
POST /git/rebasewith abasethat was renamed/deleted upstream (or typo'd) — daemon returned 500 (crash-looking) instead of a clean, retryable 400 the UI can show as "branch not found."Regression tests added:
packages/sandbox/daemon/git/rebase-onto-base.test.ts:rebaseOntoBase()throwsRebaseBaseBranchNotFoundErrorfor a base branch missing on origin (real bare-repo fixture, mirrors the existing conflict-resolution/protected-branch tests in this file).packages/sandbox/daemon/routes/git.test.ts:/git/rebaseroute returns 400 (not 500) for the same condition, mirroring the existing diff-route test for the identical scenario.Reviewer command:
bun test packages/sandbox/daemon/git/rebase-onto-base.test.ts packages/sandbox/daemon/routes/git.test.tsLocally ran:
bun run fmt,cd packages/sandbox && bunx tsc --noEmit(clean), and the targeted test file above (37 pass / 0 fail). Full CI validates the rest.Summary by cubic
Return 400 (not 500) from the sandbox rebase route when the base branch is missing on origin. Also fix fetch behavior so a missing base doesn’t prevent fetching the working branch.
RebaseBaseBranchNotFoundErrorand map it to 400 inmakeGitRebaseHandlerfor/git/rebase.RebaseBlockedErrorremains.Written for commit 5581d63. Summary will update on new commits.