fix(v1): preserve exact filenames during capture - #2241
Open
gtnv wants to merge 1 commit into
Open
Conversation
Read snapshot filenames without lossy decoding and exclude them with literal Git pathspec semantics. Added test for coverage.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c87239c. Configure here.
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.

Closes: #2196
untracked filenames lost identity in 2 spots: runtime output (replaced by invalid utf-8) and git parsed savednames (pathspecs). now, snapshotting now reads the raw bytes and rejects any unsupported filenames before capture. however, reset will treat every saved name literally. added test for coverage.
Note
Medium Risk
Touches finalize-time patch capture used for SWE grading; behavior changes only for edge-case filenames but can affect which paths are ignored or whether setup fails on invalid UTF-8 names.
Overview
Fixes two ways pre-agent filenames could be corrupted or mis-handled when building the agent diff for grading.
snapshot_untrackedno longer relies on decoded command stdout. It writesgit ls-files --othersNUL output to a unique temp file, reads it with the byte-preserving runtime API, and decodes paths as UTF-8 so invalid names raise instead of being silently rewritten.capture_patchunstaging of ignored paths now runsgit --literal-pathspecs reset, so names that look like pathspec magic (e.g.:(glob)*.py) stay literal and are not expanded when excluded from the cached diff.Adds integration coverage for literal pathspec handling during capture and for
UnicodeDecodeErroron non-UTF-8 untracked names.Reviewed by Cursor Bugbot for commit c87239c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix filename preservation during git capture by using literal pathspecs and strict UTF-8 decoding
--literal-pathspecsto thegit resetstep in git.py so filenames containing Git pathspec magic prefixes (e.g.:(glob)) are treated as literal paths rather than pathspec expressions.snapshot_untrackedto read raw bytes fromgit ls-files -zoutput via a temp file instead of decoding with replacement, so filenames are decoded strictly as UTF-8.snapshot_untrackednow raisesUnicodeDecodeErroron non-UTF-8 filenames instead of silently returning a mangled path.Macroscope summarized c87239c.