Skip to content

fix(genbi): tolerate non-list columns in model inventory - #2614

Open
Bartok9 wants to merge 1 commit into
Canner:mainfrom
Bartok9:fix/genbi-inventory-columns-list
Open

fix(genbi): tolerate non-list columns in model inventory#2614
Bartok9 wants to merge 1 commit into
Canner:mainfrom
Bartok9:fix/genbi-inventory-columns-list

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

_format_model_inventory treats a non-list columns value from YAML as empty instead of crashing on join.

Motivation

Closed #2548 put a dead model-level guard in the formatter. Maintainer: only the columns container type is reachable; models already come from load_models.

Test plan

  • test_build_inventory_tolerates_non_list_columns via compose_build_instruction

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of model inventory data when column definitions are provided in unexpected formats.
    • Build instructions now continue generating correctly and include available model and column information instead of failing.

columns is YAML-sourced; only validate the list container.
Models still arrive from load_models (already dict-filtered).
@github-actions github-actions Bot added python Pull requests that update Python code core labels Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

GenBI model inventory formatting now tolerates non-list columns and mixed column entry types. A unit test verifies that build instruction composition preserves model names and valid column content for malformed inventory inputs.

Changes

Model inventory formatting

Layer / File(s) Summary
Inventory normalization and validation
core/wren/src/wren/genbi/composer.py, core/wren/tests/unit/test_genbi_build.py
_format_model_inventory() filters supported column values and formats their names, while tests cover non-list and mixed column inputs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Canner/WrenAI#2548: Updates the same inventory formatter and adds tolerance for malformed model and column entries.

Poem

A rabbit hopped through columns bright,
Found strings and dicts in flight.
Junk was skipped, names stayed clear,
Build instructions now persevere.
“A tidy burrow!” cheered the hare.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and testing, but it omits the required failure reproduction/actual error output and the duplicate check section. Add a "What failure does this repair?" section with the observed repro and actual error output, and include the duplicate PR check.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: tolerating non-list columns in GenBI inventory formatting.
Linked Issues check ✅ Passed The change addresses #2548's relevant scope by tolerating malformed columns in inventory formatting and adding a regression test.
Out of Scope Changes check ✅ Passed No unrelated code changes are indicated beyond the inventory formatting fix and its test.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
core/wren/tests/unit/test_genbi_build.py (1)

101-116: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the filtering behavior, not only that formatting does not crash.

The test does not verify that "bare" is preserved or that numeric 3 is ignored; the existing id assertion is satisfied by the dictionary entry alone. Assert the rendered inventory lines for both models.

Based on the PR objective, the test should cover non-list-to-empty normalization and mixed-entry filtering.

Proposed assertion update
-    assert "**orders**" in text
-    assert "**customers**" in text
-    assert "id" in text
+    assert "- **orders**: \n" in text
+    assert "- **customers**: id, bare" in text
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/wren/tests/unit/test_genbi_build.py` around lines 101 - 116, Strengthen
the assertions in the compose_build_instruction test to verify rendered
inventory lines for both orders and customers, including preservation of the
bare string entry and exclusion of numeric 3. Ensure the assertions cover
non-list columns normalization to an empty list while still validating the
expected id and bare entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@core/wren/tests/unit/test_genbi_build.py`:
- Around line 101-116: Strengthen the assertions in the
compose_build_instruction test to verify rendered inventory lines for both
orders and customers, including preservation of the bare string entry and
exclusion of numeric 3. Ensure the assertions cover non-list columns
normalization to an empty list while still validating the expected id and bare
entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf1cb698-0f8d-4393-a595-e04b7482c0a6

📥 Commits

Reviewing files that changed from the base of the PR and between 99f1dbd and c48e3a5.

📒 Files selected for processing (2)
  • core/wren/src/wren/genbi/composer.py
  • core/wren/tests/unit/test_genbi_build.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant