Skip to content

fix(git): preserve whitespace in file paths (#12464) - #12465

Open
Defmon3 wants to merge 1 commit into
pingdotgg:mainfrom
Defmon3:fix/git-file-path-spaces
Open

Defmon3 wants to merge 1 commit into
pingdotgg:mainfrom
Defmon3:fix/git-file-path-spaces

Conversation

@Defmon3

@Defmon3 Defmon3 commented Sep 18, 2026 •

Copy link
Copy Markdown

Closes #12464

Git action inputs and working-tree status results trim file paths, changing " leading.txt" into "leading.txt". Preserve the exact strings in both path fields while continuing to reject empty paths.

Verification against upstream 9ea9c3d5d: the two whitespace-preservation assertions fail without the fix and pass with it. Both empty-path rejection assertions pass in both cases, giving four passing focused tests with the fix. This verifies schema decoding; a complete staging or commit operation was not tested.

Developed with Astra 6 in Codex/T3 Code and reviewed with Fable 5.1.

Summary by CodeRabbit

  • Bug Fixes
    • Git file paths now preserve leading and trailing whitespace.
    • Empty file paths are rejected consistently in stacked Git actions and version-control status results.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 18, 2026
files: Schema.Array(
Schema.Struct({
path: TrimmedNonEmptyStringSchema,
path: GitFilePath,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High src/git.ts:222

Repositories containing leading.txt or trailing.txt still report leading.txt or trailing.txt, so selecting the reported path does not identify the changed file and the targeted commit cannot stage it. parseNumstatEntries and parsePorcelainPath trim rawPath before it reaches GitFilePath; preserve Git's path bytes in those producers instead of trimming filename whitespace.

🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/contracts/src/git.ts around line 222:

Repositories containing ` leading.txt` or `trailing.txt ` still report `leading.txt` or `trailing.txt`, so selecting the reported path does not identify the changed file and the targeted commit cannot stage it. `parseNumstatEntries` and `parsePorcelainPath` trim `rawPath` before it reaches `GitFilePath`; preserve Git's path bytes in those producers instead of trimming filename whitespace.

@macroscopeapp

macroscopeapp Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — This is a small, backward-compatible Git path-validation fix with focused regression tests and no broad runtime or infrastructure changes. However, server-side path parsers still trim whitespace before these schemas receive the values, leaving the intended end-to-end fix incomplete.

Not approved because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a5c80b28-fe17-4bdb-a755-209c5f4cd3d4

📥 Commits

Reviewing files that changed from the base of the PR and between 9ea9c3d and 38b4de5.

📒 Files selected for processing (2)
  • packages/contracts/src/git.test.ts
  • packages/contracts/src/git.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a non-empty Git path schema that does not trim whitespace. Git action inputs and VCS status paths use this schema. Tests cover whitespace preservation and empty-path rejection.

Changes

Git path decoding

Layer / File(s) Summary
Path schema updates
packages/contracts/src/git.ts
Adds GitFilePath and applies it to GitRunStackedActionInput.filePaths and VCS working-tree paths.
Path decoding tests
packages/contracts/src/git.test.ts
Verifies that path whitespace is preserved and empty paths are rejected in both schemas.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 38b4d

The path decoding change preserves whitespace while continuing to reject empty paths, with focused coverage for both affected contracts. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Git path behavior being fixed: preserving leading and trailing whitespace in file paths.
Description check ✅ Passed The description explains the change, the problem, the verification performed, and the testing limits. It does not use the template headings or checklist, but it provides the main required information …
Linked Issues check ✅ Passed The changes satisfy #12464. GitFilePath uses Schema.String.check(Schema.isNonEmpty()), so it rejects empty strings without trimming whitespace. GitRunStackedActionInput.filePaths and `VcsStatusL…
Out of Scope Changes check ✅ Passed The changes stay within #12464. The production change updates only the two affected path schemas. The added tests directly verify the issue requirements. No unrelated behavior or files are shown in th…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Git file paths lose leading and trailing spaces during decoding

2 participants