fix(bundler): reject a top-level non-mapping bundle-catalogs.yml in _merge_config#3659
Open
jawwad-ali wants to merge 1 commit into
Open
fix(bundler): reject a top-level non-mapping bundle-catalogs.yml in _merge_config#3659jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
…merge_config
_merge_config silently ignored a top-level non-mapping document (a YAML list
or scalar) — `data.get("catalogs") if isinstance(data, dict) else None` made
it fall through to the built-in default stack — while the sibling reader of
the SAME file (commands_impl/catalog_config._read) raises "expected a mapping
at the top level". github#3623 already made the inner non-list `catalogs` value
agree between the two readers; this closes the remaining top-level-shape gap
so both readers reject the same malformed documents.
An empty file (load_yaml coerces to {}), absent `catalogs`, and `catalogs: []`
all remain no-ops.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
_merge_configsilently ignored a top-level non-mappingbundle-catalogs.yml(a YAML list or scalar):data.get("catalogs") if isinstance(data, dict) else Nonemade a list/scalar document fall through toNone→ early return → the built-in default stack, with no error.The sibling reader of the same file —
commands_impl/catalog_config._read— raises"expected a mapping at the top level"for exactly those documents. Merged PR #3623 already made the inner non-listcatalogsvalue agree between the two readers; this closes the remaining top-level-shape gap so both readers reject the same malformed input.Fix
Add an explicit top-level mapping guard mirroring
_read:An empty file (
load_yamlcoerces to{}), absentcatalogs, andcatalogs: []all remain no-ops.Tests
tests/contract/test_catalog_schema.py::test_toplevel_non_mapping_raises(parametrized over a top-level list and a scalar) — both raise after the fix, silently return the default stack before it. Regression tests confirm absent/emptycatalogsstill yield the built-in defaults.ruffclean; all 23 contract tests pass.AI-assisted: authored with Claude Code. Verified the message/behavior matches the
_readsibling and confirmed fail-before/pass-after.