Skip to content

Fix Many Subtle Errors#8

Open
thatch wants to merge 6 commits into
mainfrom
thatch/subtle-errors
Open

Fix Many Subtle Errors#8
thatch wants to merge 6 commits into
mainfrom
thatch/subtle-errors

Conversation

@thatch
Copy link
Copy Markdown
Member

@thatch thatch commented May 1, 2026

No description provided.

thatch added 6 commits April 29, 2026 14:30
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.
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.

1 participant