Skip to content

fix(sandbox): reject empty base string in git/diff POST endpoint - #5175

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/git-diff-empty-base-validation-w1
Jul 24, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/git-diff-empty-base-validation-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 24, 2026 •

Copy link
Copy Markdown
Collaborator

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 --noEmit in 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/diff by returning 400 instead of silently falling back to a working-tree diff. This makes client mistakes obvious and prevents confusing results.

  • Bug Fixes
    • Return 400 with { error: "base is required when provided" } when base: "" is sent.
    • Keep default behavior: missing base or an unparseable body still yields a working-tree diff.
    • Add a regression test for the empty base case.

Written for commit 357fa57. Summary will update on new commits.

Review in cubic

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
pedrofrxncx enabled auto-merge (squash) July 24, 2026 14:19
@pedrofrxncx
pedrofrxncx disabled auto-merge July 24, 2026 14:26
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 24, 2026 14:26
@pedrofrxncx
pedrofrxncx merged commit b9080b5 into main Jul 24, 2026
15 of 16 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/git-diff-empty-base-validation-w1 branch July 24, 2026 14:30
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
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