Skip to content

fix(bundler): reject falsy non-mapping requires/provides in CatalogEntry.from_dict#3667

Merged
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/catalog-entry-falsy-mapping-guard
Jul 23, 2026
Merged

fix(bundler): reject falsy non-mapping requires/provides in CatalogEntry.from_dict#3667
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/catalog-entry-falsy-mapping-guard

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

What

CatalogEntry.from_dict used data.get("requires") or {} and data.get("provides") or {}. The or {} coerces a falsy non-mapping value ([], '', 0, false) to {} before the isinstance guard 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 None explicitly (default to {}) and reject every other non-mapping.

Tests

tests/contract/test_catalog_schema.py::test_catalog_entry_rejects_falsy_non_mapping — parametrized over requires/provides × []/''/0/False; all raise after the fix, all passed silently before. ruff clean; all 29 contract tests pass.


AI-assisted: authored with Claude Code. Verified against the merged manifest mapping guards and confirmed fail-before/pass-after.

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes catalog parsing so falsy non-mapping requires and provides values are rejected.

Changes:

  • Handles absent/None mappings explicitly.
  • Adds parameterized regression coverage for falsy invalid values.
Show a summary per file
File Description
src/specify_cli/bundler/models/catalog.py Corrects mapping validation.
tests/contract/test_catalog_schema.py Adds regression tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@mnriem
mnriem merged commit f5be0ff into github:main Jul 23, 2026
14 checks passed
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.

3 participants