fix(bundler): reject falsy non-list bundles/contributed_components in records#3666
Merged
mnriem merged 1 commit intoJul 23, 2026
Merged
Conversation
… 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>
Contributor
There was a problem hiding this comment.
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
Nonelist 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
Collaborator
|
Thank you! |
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
Both readers of
.specify/bundle-records.jsondefaulted their list fields withdata.get(...) or []before theisinstance(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 forcontributed_components) was coerced to[]and silently read as "no bundles"/"no components" instead of raisingCorrupt records file … must be a list. Only a truthy non-list (e.g."x") reached the guard.Fix
Handle
Noneexplicitly (default to[]) and reject every other non-list, mirroring the mergedrequires/provides/integrationmanifest guards (#3629, #3661) and thecatalog_config._readsibling reader.Tests
tests/unit/test_bundler_records.py:test_load_records_rejects_falsy_non_list_bundles— parametrized0,False,'',{}test_from_dict_rejects_falsy_non_list_contributed_components— same setAll raise after the fix; all passed silently before.
ruffclean; the full records suite passes (the one Windows-onlytest_save_records_refuses_symlinked_specify_escapefailure 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.