Repository navigation
fix(sandbox): reject empty base string in git/diff POST endpoint - #5175
Merged
Merged
Conversation
The /git/diff handler accepted base: "" (empty string) in the request body but silently fell back to returning a working-tree diff instead of treating it as a validation error. An empty base is a client mistake, not a request for the default behavior — rejecting it with 400 makes the intent explicit and catches bugs earlier. Added regression test to verify empty base strings are rejected.
pedrofrxncx
enabled auto-merge (squash)
July 24, 2026 14:19
pedrofrxncx
disabled auto-merge
July 24, 2026 14:26
pedrofrxncx
enabled auto-merge (squash)
July 24, 2026 14:26
decocms Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
PR: #5175 fix(sandbox): reject empty base string in git/diff POST endpoint Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.22.4 -> 1.22.5 - deploy/helm/sandbox-env (chart 0.9.23) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.22.5 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.
Summary
The /git/diff handler accepted
base: ""(empty string) in the request body but silently fell back to returning a working-tree diff instead of treating it as a validation error. An empty base is a client mistake, not a request for the default behavior — rejecting it with 400 makes the intent explicit and catches bugs earlier.Failure scenario
Client sends
POST /git/diff { base: "" }→ handler returns 200 with working-tree diff instead of 400 validation error → client gets unexpected result (working-tree diff when they thought they were requesting a base-branch diff).Regression test
Added
"diff POST rejects an empty base string as invalid input"to verify empty base strings are rejected with 400 and a clear error message.Net diff
-4 / +33: Added validation branch in the handler + added 1 regression test.
Verification
bun run fmt✓bunx tsc --noEmitin packages/sandbox ✓bun test packages/sandbox/daemon/routes/git.test.ts— all 36 tests pass ✓Summary by cubic
Reject empty base strings in
POST /git/diffby returning 400 instead of silently falling back to a working-tree diff. This makes client mistakes obvious and prevents confusing results.{ error: "base is required when provided" }whenbase: ""is sent.baseor an unparseable body still yields a working-tree diff.basecase.Written for commit 357fa57. Summary will update on new commits.