fix(bundler): reject falsy non-mapping requires/provides in CatalogEntry.from_dict#3667
Open
jawwad-ali wants to merge 1 commit into
Open
fix(bundler): reject falsy non-mapping requires/provides in CatalogEntry.from_dict#3667jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
…try.from_dict
CatalogEntry.from_dict used `data.get("requires") or {}` and
`data.get("provides") or {}`, so a FALSY non-mapping ([], '', 0, false) was
coerced to {} before the isinstance guard — a corrupt catalog entry passed
silently. Only a truthy non-mapping was rejected.
Handle None explicitly and reject every other non-mapping, mirroring the
merged manifest requires/provides/integration guards (github#3629, github#3661).
🤖 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
CatalogEntry.from_dictuseddata.get("requires") or {}anddata.get("provides") or {}. Theor {}coerces a falsy non-mapping value ([],'',0,false) to{}before theisinstanceguard runs — so a corrupt catalog entry with e.g.requires: []passed validation silently. Only a truthy non-mapping (e.g.provides: "extensions") reached the guard and raised.This is the same falsy-coercion hole fixed for the bundle manifest in #3629 / #3661 and for records in a sibling PR — this closes it for catalog entries.
Fix
Handle
Noneexplicitly (default to{}) and reject every other non-mapping.Tests
tests/contract/test_catalog_schema.py::test_catalog_entry_rejects_falsy_non_mapping— parametrized overrequires/provides×[]/''/0/False; all raise after the fix, all passed silently before.ruffclean; all 29 contract tests pass.AI-assisted: authored with Claude Code. Verified against the merged manifest mapping guards and confirmed fail-before/pass-after.