Skip to content

fix(bundler): reject falsy non-list bundles/contributed_components in records#3666

Open
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/bundler-records-falsy-non-list-guard
Open

fix(bundler): reject falsy non-list bundles/contributed_components in records#3666
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/bundler-records-falsy-non-list-guard

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

What

Both readers of .specify/bundle-records.json defaulted their list fields with data.get(...) or [] before the isinstance(list) guard, making the guard dead code for falsy non-list values:

  • load_records (L124): bundles = data.get("bundles") or []
  • InstalledBundleRecord.from_dict (L58): components_raw = data.get("contributed_components") or []

A corrupt bundles: 0 / bundles: {} (or the same for contributed_components) was coerced to [] and silently read as "no bundles"/"no components" instead of raising Corrupt records file … must be a list. Only a truthy non-list (e.g. "x") reached the guard.

Fix

Handle None explicitly (default to []) and reject every other non-list, mirroring the merged requires/provides/integration manifest guards (#3629, #3661) and the catalog_config._read sibling reader.

Tests

tests/unit/test_bundler_records.py:

  • test_load_records_rejects_falsy_non_list_bundles — parametrized 0, False, '', {}
  • test_from_dict_rejects_falsy_non_list_contributed_components — same set

All raise after the fix; all passed silently before. ruff clean; the full records suite passes (the one Windows-only test_save_records_refuses_symlinked_specify_escape failure is a pre-existing symlink-privilege limitation of the local box, unrelated to this change, and passes on CI/Linux).


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

… records

load_records and InstalledBundleRecord.from_dict defaulted their list fields
with `data.get(...) or []` BEFORE the isinstance(list) guard, so a FALSY
non-list value (0, '', False, {}) was coerced to [] and the guard became dead
code — a corrupt .specify/bundle-records.json was silently read as "no
bundles"/"no components" instead of raising. Only an absent/None value should
mean empty.

Handle None explicitly and reject every other non-list, mirroring the merged
requires/provides/integration guards (github#3629, github#3661) and the catalog_config
sibling reader.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jawwad-ali
jawwad-ali requested a review from mnriem as a code owner July 22, 2026 19:11
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