Fix Many Subtle Errors#8
Open
thatch wants to merge 6 commits into
Open
Conversation
The or-chain used truthiness to pick the matched group, so an empty
string key ("") would fall through all groups and leave name=None,
causing _escape to raise AttributeError. Use is-not-None checks
instead so empty string keys are handled correctly.
When format= is omitted and the file extension is unrecognised, detect_format returns None. The bare assert raised AssertionError inside the except block, replacing the original exception with an opaque crash. Fall back to the same filename-only ParseError that other unlocatable exceptions get instead.
jsonpath_to_pointer raises ValueError for paths it cannot parse, such as those containing wildcard segments like $[...] that msgspec emits when the top-level type is a dict. The except ValueError branch was marked pragma: no cover because it was thought unreachable, but it is reachable and caused the original exception to re-raise without any filename information. Apply the same filename-only ParseError fallback used by other unlocatable errors instead.
…anager When the caller passed format='YAML' or another uppercase variant, build_source_map raised ValueError: Unknown format, which escaped the except handler and buried the original validation exception as __context__. Normalise format to lowercase so 'YAML', 'JSON', 'TOML' all work, and validate the normalised value against known formats so truly unknown values still get the filename-only ParseError fallback instead of leaking a bare ValueError.
When closest_entry returns None (e.g. empty YAML document with a JSONPath validation error), the code re-raised the original exception via bare 'raise exc', losing the filename. Apply the same filename-only ParseError fallback used by other unlocatable paths.
build_source_map accepts 'yml' as a synonym for 'yaml', but the validation added to catch unknown formats did not include 'yml', so passing format='yml' silently fell back to filename-only errors with no line numbers. Normalise 'yml' to 'yaml' before the check.
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.
No description provided.