Skip to content

fix(gcode): create parent directory when writing G-code - #168

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/write-gcode-creates-parent-dir
Jun 25, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/write-gcode-creates-parent-dir

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Bug B3 from the latent-bug audit.

Problem

write_gcode called target.write_text(...) without ensuring the parent directory existed, so fiberpath plan --output subdir/out.gcode (where subdir/ doesn't exist) crashed with a raw FileNotFoundError traceback. plot_command already guarded this with output.parent.mkdir(parents=True, exist_ok=True) — plan didn't.

Fix

Add the same mkdir(parents=True, exist_ok=True) inside write_gcode, so every caller (CLI plan and any other) is covered, not just one command.

TDD

  • RED: test_write_gcode_creates_missing_parent_dirs failed with FileNotFoundError before the fix.
  • GREEN: passes after. Full suite 123 passed, ruff/format/mypy clean.

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.
@CameronBrooks11
CameronBrooks11 merged commit d0e4bd2 into main Jun 25, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/write-gcode-creates-parent-dir branch June 25, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant