fix(sandbox): return 409 instead of 500 for tokenless GitHub publish - #5211
Merged
Conversation
pedrofrxncx
enabled auto-merge (squash)
July 24, 2026 17:47
decocms Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
PR: #5211 fix(sandbox): return 409 instead of 500 for tokenless GitHub publish Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.22.6 -> 1.22.7 - deploy/helm/sandbox-env (chart 0.9.25) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.22.7 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 fix in the sandbox daemon's git/publish route, in the same family as #5189/#5150/#5144/#5175 (the recurring "surface a client/data condition as 4xx instead of a raw 500" pattern in
packages/sandbox/daemon/routes/git.ts).publish()already refuses a tokenless GitHub origin (cloneUrlHasCredentialscheck) with a clear message, but threw a plainError, whichmakeGitPublishHandler's catch-all falls through to a generic 500 — the same opaque-server-error UX the prior fixes in this file eliminated for protected-branch/detached-HEAD refusals. A maintainer wants this because the daemon's own convention (seePublishBlockedErrorright above this check, used for detached HEAD / protected branch) is that a refusal caused by current repo/config state, not a server fault, should map to 409 so the UI can show an actionable message instead of a scary crash.Failure scenario: a sandbox whose GitHub origin has no embedded credentials (project not yet connected to GitHub) calls POST /git/publish → daemon returns 500 with no structured error the UI can act on, even though the underlying condition ("connect GitHub and restart the sandbox") is entirely a client-actionable state, not a crash.
Fix: reuse the existing
PublishBlockedError(already mapped to 409 in the handler) instead of a bareErrorfor this refusal — one-line change, no behavior change to the message or control flow. Regression test added:publish route returns 409 (not 500) for a tokenless github originin git.test.ts, mirroring the existingpublish route returns 409 (not 500) for a protected-branch refusaltest right above it.Reviewer command:
bun test packages/sandbox/daemon/routes/git.test.tsLocally ran:
bun run fmt,bunx tsc --noEmit(packages/sandbox), and the single targeted test file above (38 pass). Full CI validates the rest.Summary by cubic
Return 409 Conflict instead of 500 from sandbox
git/publishwhen the GitHub remote has no credentials. This turns a client-actionable state into a clear UI message instead of a generic server error.PublishBlockedErrorfor tokenless GitHub origins so the route returns 409.Written for commit 5591464. Summary will update on new commits.