Skip to content

fix(genbi): harden non-dict apps.yml entries in list/get/register - #2587

Open
Bartok9 wants to merge 2 commits into
Canner:mainfrom
Bartok9:fix/genbi-list-nonduct-entries
Open

fix(genbi): harden non-dict apps.yml entries in list/get/register#2587
Bartok9 wants to merge 2 commits into
Canner:mainfrom
Bartok9:fix/genbi-list-nonduct-entries

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Single PR for hand-edited apps.yml non-dict entries (folds #2583 + prior #2587 list work):

Path Behavior
list prints invalid entry on stderr, continues; non-dict deploy treated as empty
get_app non-dict → None (CLI "not registered")
register_app replaces truthy non-dict instead of TypeError on item assignment
update_app KeyError when missing/non-dict

Reproduction (base / before)

apps: {bad: "not-a-map"}
register_app → TypeError: 'str' object does not support item assignment
list with deploy: "https://x" on a valid entry → AttributeError: 'str' object has no attribute 'get'

Verification

cd core/wren && python -m pytest tests/unit/test_genbi_index.py tests/unit/test_genbi_list_nonduct.py -q

Summary by CodeRabbit

  • Bug Fixes

    • Improved resilience when listing apps with malformed or incomplete data.
    • Invalid app entries are skipped and reported without preventing valid apps from appearing.
    • Incomplete deployment details are handled safely.
    • App registration now replaces invalid stored entries, while updates provide a clear missing-app error.
  • Tests

    • Added coverage for malformed app and deployment data scenarios.

@github-actions github-actions Bot added python Pull requests that update Python code core labels Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dc845f9f-205c-42dc-9096-73e2c85ae947

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc97c3 and 7013a49.

📒 Files selected for processing (1)
  • core/wren/tests/unit/test_genbi_list_nonduct.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/wren/tests/unit/test_genbi_list_nonduct.py

Walkthrough

GenBI index operations now handle non-mapping app entries safely. The app list command skips malformed entries, normalizes invalid deployment data, and safely reads deployment URLs. Unit tests cover index operations and list behavior.

Changes

GenBI malformed data handling

Layer / File(s) Summary
Validate malformed index entries
core/wren/src/wren/genbi/index.py, core/wren/tests/unit/test_genbi_index.py
Index access returns None for invalid entries. Registration replaces invalid entries with scaffolded mappings. Updates raise KeyError for missing or invalid entries.
Validate malformed list entries
core/wren/src/wren/genbi/cli.py, core/wren/tests/unit/test_genbi_list_nonduct.py
list_apps skips invalid app entries, normalizes non-dictionary deployment values, safely reads last_url, and reports invalid entries.

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

Possibly related PRs

  • Canner/WrenAI#2406: Both changes modify genbi/index.py to handle malformed app-index entries.
  • Canner/WrenAI#2583: Both changes update GenBI index and CLI handling for non-dictionary app entries.

Suggested reviewers: goldmedal

Poem

A rabbit checks each app entry,
Skips malformed data gently.
Valid apps remain in view,
Safe deploy fields pass through too.
The index stays steady and true.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the GenBI fix for malformed non-dictionary apps.yml entries and names the main affected operations.
Description check ✅ Passed The description includes the change summary, observed failures with actual error output, and targeted test command; the duplicate-check section is missing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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_list_nonduct.py (1)

13-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover malformed deploy values.

This test verifies invalid app entries but not the new non-dictionary deploy handling in core/wren/src/wren/genbi/cli.py lines 210-214. Add a valid app whose deploy value is a scalar and assert listing succeeds without a URL suffix.

Proposed test extension
             "apps": {
                 "good": {"data_mode": "snapshot", "status": "ready"},
                 "bad": "not-a-mapping",
+                "bad-deploy": {
+                    "data_mode": "snapshot",
+                    "status": "ready",
+                    "deploy": "not-a-mapping",
+                },
             },
...
     assert "good" in result.stdout
+    assert "bad-deploy  [snapshot, ready]" in result.stdout
     assert "invalid entry" in result.stdout
🤖 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_list_nonduct.py` around lines 13 - 27, Extend
the test around save_index and the genbi_app list invocation with a valid app
whose deploy field is a scalar rather than a mapping. Keep the successful
listing assertions, and verify that this app is listed without a URL suffix
while the existing malformed app still produces the invalid-entry output.
🤖 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_list_nonduct.py`:
- Around line 13-27: Extend the test around save_index and the genbi_app list
invocation with a valid app whose deploy field is a scalar rather than a
mapping. Keep the successful listing assertions, and verify that this app is
listed without a URL suffix while the existing malformed app still produces the
invalid-entry output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c0ae7cda-7e1c-4dd0-8e53-a4f05b649f76

📥 Commits

Reviewing files that changed from the base of the PR and between d472877 and 9921cdd.

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

- list: report invalid entries; treat non-dict deploy as empty
- get_app: non-dict → None (not registered)
- register_app: replace truthy non-dict instead of TypeError
- update_app: KeyError on missing/non-dict

Addresses goldmedal review on Canner#2583/Canner#2587 (single PR).
@Bartok9 Bartok9 changed the title fix(genbi): tolerate non-dict apps entries in list fix(genbi): harden non-dict apps.yml entries in list/get/register Aug 7, 2026
@Bartok9
Bartok9 force-pushed the fix/genbi-list-nonduct-entries branch from 9921cdd to 0fc97c3 Compare August 7, 2026 04:15
@Bartok9

Bartok9 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@goldmedal folded the #2583 + #2587 work into this single PR and rebased on current main.

  • list covers non-dict entries and non-dict deploy blocks (the crash you reproduced)
  • register_app no longer TypeErrors on truthy non-dicts
  • get_app treats non-dict as unregistered
  • update_app raises KeyError for missing/non-dict (callers still go through _require_registered first)

Closing #2583 as the duplicate against the same files.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@core/wren/tests/unit/test_genbi_list_nonduct.py`:
- Around line 44-46: Update the test around the genbi_app list invocation to
assert that the invalid non-dictionary deploy value, including “https://x”, is
absent from result.stdout while preserving the existing successful exit-code and
app-name assertions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 471b8ba2-d888-4d21-b972-8bbec0268150

📥 Commits

Reviewing files that changed from the base of the PR and between 9bdae39 and 0fc97c3.

📒 Files selected for processing (4)
  • core/wren/src/wren/genbi/cli.py
  • core/wren/src/wren/genbi/index.py
  • core/wren/tests/unit/test_genbi_index.py
  • core/wren/tests/unit/test_genbi_list_nonduct.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/wren/src/wren/genbi/cli.py

Comment thread core/wren/tests/unit/test_genbi_list_nonduct.py
CodeRabbit: non-dict deploy must not render last_url.
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