Skip to content

Propagate swallowed read errors in mod generate - #121

Merged
argonui merged 1 commit into
mainfrom
fix/propagate-generate-errors
Aug 4, 2026
Merged

Propagate swallowed read errors in mod generate#121
argonui merged 1 commit into
mainfrom
fix/propagate-generate-errors

Conversation

@argonui

@argonui argonui commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #97 — two places in the generate path discarded errors, turning a misconfiguration into silently missing data.

  • tryPut (mod/generate.go) previously did o, _ = fun(filename); // ignore error for now. It now propagates the error when a *_path key is present with a non-empty filename and the read fails — a mod referencing a file that isn't there fails loudly. When the source key is simply absent from config, the lenient behavior is unchanged (a normal optional field stays a zero-valued no-op). tryPut now returns error, and the three loops in generate() propagate it.
  • ListFilesAndFolders("") no longer has its error dropped, so an unreadable objects directory surfaces as an error instead of masquerading as "no objects".

Tests

  • TestGenerateBrokenPointer — a present *_path pointing at a missing file now errors, and the error names the missing file.
  • TestGenerateAbsentOptionalKey — a config with an absent optional key still succeeds unchanged.

go build ./..., go vet ./..., and go test ./... all pass. Go 1.18 compatible.

🤖 Generated with Claude Code

tryPut discarded the error from reading a *_path target, so a mod
referencing a missing file silently produced an empty value. It now
returns an error when a present, non-empty *_path pointer fails to
resolve, while staying lenient for absent optional keys. The dropped
error from ListFilesAndFolders is also propagated so an unreadable
objects dir no longer masquerades as "no objects".

Fixes #97

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@argonui
argonui force-pushed the fix/propagate-generate-errors branch from e9332cf to 4d04a1a Compare August 4, 2026 02:26
@argonui
argonui merged commit 2ed9c26 into main Aug 4, 2026
1 check failed
@argonui
argonui deleted the fix/propagate-generate-errors branch August 4, 2026 02:26
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.

Read errors are silently swallowed in generate

1 participant