Skip to content

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

Merged
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/bundler-records-falsy-non-list-guard
Jul 23, 2026
Merged

fix(bundler): reject falsy non-list bundles/contributed_components in records#3666
mnriem merged 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>

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 record parsing so falsy non-list values are rejected instead of silently treated as empty lists.

Changes:

  • Explicitly defaults only missing or None list fields.
  • Adds regression coverage for falsy invalid values.
Show a summary per file
File Description
src/specify_cli/bundler/models/records.py Corrects list validation for record fields.
tests/unit/test_bundler_records.py Tests falsy non-list rejection.

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 34bbaaf into github:main Jul 23, 2026
14 checks passed
@mnriem

mnriem commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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