Repository navigation
fix(config): handle directory and non-UTF-8 wind definition inputs - #169
Merged
Merged
Conversation
load_wind_definition only caught JSONDecodeError and ValidationError, so a directory path raised IsADirectoryError and a binary/non-UTF-8 file raised UnicodeDecodeError straight out of read_text. The API surfaced these as HTTP 500 (instead of 4xx) and the CLI as a raw traceback. Wrap the read and map OSError/UnicodeDecodeError to WindFileError, which callers already handle. Adds regression tests for a directory and a non-UTF-8 file.
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.
Bug B4 (loader half) from the latent-bug audit — covers the
plan/validatepaths (API + CLI).Problem
load_wind_definitiononly caughtjson.JSONDecodeErrorandValidationError. Theread_text(encoding="utf-8")call itself can raise:IsADirectoryError(anOSError) when the path is a directory, andUnicodeDecodeErroron a binary / non-UTF-8 file.Neither is
WindFileError, so the API returned HTTP 500 for/plan/from-fileand/validate/from-file, and the CLI printed a raw traceback, for ordinary bad input.Fix
Wrap the read and map
(OSError, UnicodeDecodeError)toWindFileError— the same error the API maps to 4xx and the CLI maps to a cleanBadParameter.TDD
..._on_directory_raises_windfileerror(rawIsADirectoryError) and..._on_non_utf8_file_raises_windfileerrorfailed before the fix.