Skip to content

fix(seed): fail on per-file write errors instead of exiting 0 - #725

Merged
dubadub merged 1 commit into
cooklang:mainfrom
drawmeanelephant:fix/707-seed-write-failures
Oct 15, 2026
Merged

dubadub merged 1 commit into
cooklang:mainfrom
drawmeanelephant:fix/707-seed-write-failures

Conversation

@drawmeanelephant

Copy link
Copy Markdown
Contributor

Closes #707

cook seed discarded each fs::write result inside .map(), so a blocked file (e.g. a directory named Risotto.cook) produced exit 0 with no file and no message. The loop now propagates write/mkdir errors with the file path.

Test plan

  • mkdir Risotto.cook && cook seed . prints Error: Failed to write seed file: ./Risotto.cook and exits 1

The seed loop mapped each embedded file to its `fs::write` result and
dropped the `Result` on the floor, so `cook seed .` reported success
while leaving files unwritten — for example when a directory already
sat where a seed file belonged. Propagate the error with context so the
failed file is named and the command exits nonzero.

Closes #707

@LeMyst LeMyst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. The .map() that discarded the io::Result is now a loop with ? on create_dir_all and fs::write, so the repro from #707 (mkdir Risotto.cook; cook seed .) fails and names the file. Optional: that repro would make an easy integration test. Merges cleanly with #724.


🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.

@dubadub
dubadub merged commit 2edb7e8 into cooklang:main Oct 15, 2026
6 checks passed
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.

cook seed silently swallows per-file write failures and exits 0

3 participants