Repository navigation
fix(sandbox): remove a sandbox directory whose build failed - #2357
Merged
Merged
Conversation
Config::build creates the sandbox's directory, then any later failure (fs-mapping validation, the synth user/group config, any step of Sandbox::new, including hardlinking or copying inputs) returned before a Sandbox existed, so its Drop never removed the directory: a failed build left a partial tree behind, and the next one made a new directory. A RemoveUnlessKept guard removes the directory unless the Sandbox was built (its Drop owns cleanup from then on), and stays out of the way when keep_dirs is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Contributor
|
Approved: no findings at Nothing to do. Clobber: none seen. |
norrietaylor
approved these changes
Oct 19, 2026
Member
Author
|
recheck |
bryan-minimal
enabled auto-merge
October 22, 2026 19:00
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.
Config::buildcreates the sandbox's directory, then can still fail before aSandboxexists to own it: fs-mapping validation, the synth user/group config, or any step ofSandbox::new(hardlinking inputs, and copying them since #2234). Every one of those returns with the directory still there, because onlySandbox'sDropremoves it. A failed build left a partial tree behind, and the next build made a new uniquely-named directory instead of reusing it. CodeRabbit raised this on #2234 for the new copy path, but it applies to all of them.Change: a
RemoveUnlessKeptguard is armed right after the directory is created. Any early return removes the directory (and logs if removal fails). OnceSandbox::newsucceeds, the guard is disarmed and theSandbox's ownDropowns cleanup, as before. Withkeep_dirsset, the guard is never armed, so a failed build's directory is kept for inspection, matching the debugging option's intent.Testing (Linux): fmt is clean,
clippy -p sandbox --all-targets -D warningsis clean, and the new testa_failed_build_removes_its_directorypasses. It drivesConfig::buildintoSandbox::new'sMappedFilerejection, which happens after the directory and its synth config exist, and asserts the base directory is empty afterwards.Follow-up to a review thread on #2234.
🤖 Generated with Claude Code
Summary by CodeRabbit