fix(opencode): handle snapshot exclude write failure gracefully - #42517
Open
MoerAI wants to merge 2 commits into
Open
fix(opencode): handle snapshot exclude write failure gracefully#42517MoerAI wants to merge 2 commits into
MoerAI wants to merge 2 commits into
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential duplicate found:
Why it's related: PR #37494 appears to address the exact same issue (closes #37493) with an identical fix approach. Both PRs handle the snapshot exclude write failure gracefully by converting from |
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.
Issue for this PR
Closes #37493
Type of change
What does this PR do?
sync()inpackages/opencode/src/snapshot/index.tswrote the snapshot'sinfo/excludewithEffect.orDie. That promotes a recoverable write failure into a defect, and becausesync()runs insideadd()->track()/patch(), the defect escapes into the session and kills the turn the user is in the middle of.Refreshing that exclude file is advisory, so it shouldn't be able to do that. Every other git step in this file already degrades instead of dying -
stage(),add(),patch()andcleanup()all log a warning and carry on.sync()now does the same: theensureDir+ write are wrapped together, and a failure logsfailed to write snapshot excludeand continues. Ignored files are still filtered separately byignore()inadd(), so a stale exclude file doesn't leak gitignored files into the snapshot.Only the v1 path is touched -
packages/core/src/snapshot.tsalready handles this.How did you verify your code works?
Added
git info exclude write failure keeps tracking alivetotest/snapshot/snapshot.test.ts. It forces the write to fail by turning<gitdir>/info/excludeinto a directory. On current dev that test dies withAlreadyExists: FileSystem.writeFile (...); with the fixtrack()returns a hash. Full file is 54 pass / 3 skip / 0 fail.To confirm it outside the test runner I ran the real CLI against a throwaway git repo with the same directory planted:
opencode debug snapshot trackexits 1 withError: Unexpected errorlevel=WARN message="failed to write snapshot exclude" target="..." error="PlatformError: AlreadyExists: FileSystem.writeFile (...)"bun run typecheckinpackages/opencodeis clean.Screenshots / recordings
Not a UI change.
Checklist