Repository navigation
fix(sandbox): return 400 instead of 500 when the diff base branch isn't on origin - #5142
Merged
Merged
Conversation
pedrofrxncx
enabled auto-merge (squash)
July 23, 2026 21:46
decocms Bot
pushed a commit
that referenced
this pull request
Jul 23, 2026
PR: #5142 fix(sandbox): return 400 instead of 500 when the diff base branch isn't on origin Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.22.1 -> 1.22.2 - deploy/helm/sandbox-env (chart 0.9.20) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.22.2 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.
Bug found while auditing
packages/sandbox/daemon/routes/git.ts:computeDiffAgainstBase()(used byPOST /git/diffwhen abaseis supplied) threw a plainErrorwhen the requested base branch doesn't exist onorigin(typo, deleted branch). That fell through the handler's genericcatchand surfaced as an opaque 500, the same class of bug already fixed elsewhere in this file forInvalidRemoteBranchNameError(400) andPublishBlockedError/RebaseBlockedError(409) — this one case was missed.A maintainer wants this because a bad/stale base branch is a client input problem, not a server fault; the UI can distinguish and retry/report accordingly instead of treating it as a crash.
Failure scenario: client POSTs
/git/diffwith a syntactically-validbase(e.g. a deleted or mistyped branch name) that has no matching ref onorigin— previously a 500 with a generic error body; now a 400 with the same descriptive message ("Base branch '' not found on origin"). Added a regression test (diff POST returns 400 (not 500) when the base branch isn't on origin) asserting the new status/body.Reviewer check:
bun test packages/sandbox/daemon/routes/git.test.ts(33 pass, includes the new test).Locally verified:
bun run fmt,cd packages/sandbox && bunx tsc --noEmit(clean), and the targeted test file above. Full CI validates the rest.Summary by cubic
Return 400 (Bad Request) instead of 500 when
POST /git/diffis called with a base branch that isn’t on origin. This clarifies client input errors so the UI can handle them.BaseBranchNotFoundErrorand mapped it to 400 inpackages/sandbox/daemon/routes/git.ts.packages/sandbox/daemon/routes/git.test.ts.Written for commit 97b2091. Summary will update on new commits.