Propagate swallowed read errors in mod generate - #121
Merged
Conversation
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
force-pushed
the
fix/propagate-generate-errors
branch
from
August 4, 2026 02:26
e9332cf to
4d04a1a
Compare
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.
Summary
Fixes #97 — two places in the generate path discarded errors, turning a misconfiguration into silently missing data.
tryPut(mod/generate.go) previously dido, _ = fun(filename); // ignore error for now. It now propagates the error when a*_pathkey 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).tryPutnow returnserror, and the three loops ingenerate()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*_pathpointing 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 ./..., andgo test ./...all pass. Go 1.18 compatible.🤖 Generated with Claude Code