Repository navigation
fix(gcode): create parent directory when writing G-code - #168
Merged
Merged
Conversation
write_gcode wrote to the destination path without ensuring its parent directory existed, so 'fiberpath plan --output subdir/out.gcode' into a non-existent directory crashed with a raw FileNotFoundError traceback. The plot command already guarded this. Mirror it in write_gcode so every caller benefits. Adds a regression test for nested missing dirs.
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.
Bug B3 from the latent-bug audit.
Problem
write_gcodecalledtarget.write_text(...)without ensuring the parent directory existed, sofiberpath plan --output subdir/out.gcode(wheresubdir/doesn't exist) crashed with a rawFileNotFoundErrortraceback.plot_commandalready guarded this withoutput.parent.mkdir(parents=True, exist_ok=True)—plandidn't.Fix
Add the same
mkdir(parents=True, exist_ok=True)insidewrite_gcode, so every caller (CLIplanand any other) is covered, not just one command.TDD
test_write_gcode_creates_missing_parent_dirsfailed withFileNotFoundErrorbefore the fix.