[#165] Abort cleanly when remote or local file: content cannot be fetched#170
Merged
Conversation
Introduce ContentFetchError to represent fetch failures cleanly. FileItem.fetch_content() now raises ContentFetchError instead of logging and suppressing exceptions, preventing a secondary Jinja2 TypeError traceback from obscuring the root cause. GenerateCommand.execute() catches ContentFetchError alongside GenerateConfigError and TemplateVariableError, logging only the root-cause message and exiting with code 1. Closes #165
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 #165.
When a
file:item referenced content that could not be fetched, the error was logged but silently suppressed. Generation then continued withself.contentunset, causing a secondary Jinja2TypeErrortraceback that hid the original root cause.Changes
structkit/file_item.pyContentFetchError— a clean domain exception for content fetch failures.FileItem.fetch_content()now raisesContentFetchErrorinstead of logging and suppressing the exception.structkit/commands/generate.pyContentFetchErrorfromfile_item.GenerateCommand.execute()catchesContentFetchErroralongsideGenerateConfigErrorandTemplateVariableError, logging only the root-cause message and exiting with code 1.tests/test_commands_more.pytest_generate_missing_local_file_ref_exits_cleanly: verifies a missingfile://target exits 1 with a clean root-cause message, noTraceback, and no output file created.test_generate_remote_fetch_failure_exits_cleanly: verifies a mocked remote HTTP fetch failure exits 1 cleanly with the same guarantees.Acceptance criteria
file://target exits 1 with a clean root-cause message and noTraceback.file://and one mocked remote failure.