fix(bridge): confirm before wiping non-empty convert output dir - #14174
Merged
ndeloof merged 1 commit intoSep 3, 2026
Conversation
`bridge convert -o <dir>` unconditionally ran `os.RemoveAll` on the output directory and discarded any error, so a typo (`-o .`, `-o $PWD`, `-o ~`) silently destroyed unrelated user data. An empty or missing output directory is still created silently, but a non-empty one now requires explicit confirmation (prompted interactively, or via the new `--yes` flag for scripts/CI) before being wiped. Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
docker-agent
reviewed
Sep 3, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The safety guard is correctly implemented. prepareOutputDir checks for a non-empty directory, prompts for confirmation (or auto-confirms via --yes), and only then calls os.RemoveAll + os.MkdirAll — all with proper error propagation. The --yes flag is wired correctly through the CLI layer. The new FileAbsent / FileContains check helpers and the two Scenario-based e2e tests cover both the confirmed and declined paths cleanly.
Two hypotheses were raised and investigated during review:
- Non-TTY stdin behaviour without
--yes:NewPromptalready branches onstdin.IsTerminal()and returns aPipeimplementation for non-TTY contexts.Pipe.Confirmreads viafmt.Fscanln; on EOF it silently gets an empty string,StringToBool("")→false, and the convert is declined with an explicit error — no hang, no silent data destruction. ✅ Dismissed. - E2E declined-path test hanging: The test intentionally exercises the non-TTY decline path. Because
Pipe.Confirmreturnsfalseon EOF stdin, the command exits with code 1 and the guard file is untouched — exactly whatExitCode(1)+FileContainsassert. ✅ Dismissed.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ndeloof
approved these changes
Sep 3, 2026
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.
What I did
bridge convert -o <dir>unconditionally ranos.RemoveAllon the output directory and discarded any error, so a typo (-o .,-o $PWD,-o ~) silently destroyed unrelated user data.An empty or missing output directory is still created silently, but a non-empty one now requires explicit confirmation (prompted interactively, or via the new
--yesflag for scripts/CI) before being wiped.Related issue
https://docker.atlassian.net/browse/DDB-683
(not mandatory) A picture of a cute animal, if possible in relation to what you did
