Skip to content

fix(context): harden description checks for bad MDL rows - #2616

Open
Bartok9 wants to merge 1 commit into
Canner:mainfrom
Bartok9:fix/context-check-descriptions-guards
Open

fix(context): harden description checks for bad MDL rows#2616
Bartok9 wants to merge 1 commit into
Canner:mainfrom
Bartok9:fix/context-check-descriptions-guards

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Description lint crashed on non-dict models/views/columns or non-dict properties.

Verification

pytest tests/unit/test_check_descriptions_guards.py -q
# 1 passed

Summary by CodeRabbit

  • Bug Fixes

    • Improved description validation to safely handle malformed or incomplete model, view, and column data.
    • Validation now skips invalid entries instead of failing and continues reporting missing descriptions accurately.
  • Tests

    • Added coverage for mixed valid and invalid model, view, and column data during strict validation.

_check_descriptions assumed models/views/columns/properties were always
well-typed. Skip non-dict rows so validation cannot crash the CLI.
@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

Description validation now safely handles malformed model, view, column, and property structures. A unit test verifies that invalid entries are skipped while missing descriptions still produce expected warnings.

Changes

Description validation guards

Layer / File(s) Summary
Harden description checks
core/wren/src/wren/context.py, core/wren/tests/unit/test_check_descriptions_guards.py
Description checks normalize manifest collections, skip non-dict entries, validate strict-mode columns, and test warnings for missing model, column, and view descriptions.

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

Possibly related PRs

  • Canner/WrenAI#2562: Adds similar defensive handling for malformed manifest model entries in a related formatting function.

Suggested reviewers: goldmedal

Poem

I nibbled malformed shapes with care,
And skipped the crumbs that weren’t quite there.
Models and views now pass the gate,
While missing words still warn their fate.
Hop, hop—safe checks celebrate!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes summary and testing, but omits the required failure report and duplicate check sections for a fix PR. Add the failure reproduction/actual error output under "What failure does this repair?" and include the duplicate check details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the change: it hardens description validation against malformed MDL rows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

Actionable comments posted: 1

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

4-23: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Test the public validation path and collection-shape guards.

This test invokes _check_descriptions directly, so it cannot catch the unsafe validate_manifest dry-plan loop for malformed views. Add a regression through validate_manifest with a non-dictionary view, plus non-list models and views cases.

🤖 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_check_descriptions_guards.py` around lines 4 - 23,
Add regression coverage through the public validate_manifest path rather than
calling _check_descriptions directly. Include malformed manifests with a
non-dictionary view and non-list models and views, and assert validation
completes safely with the expected result; preserve coverage for malformed model
and column entries where applicable.
🤖 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/src/wren/context.py`:
- Around line 1591-1596: Normalize and filter raw view entries in
validate_manifest before the dry-planning logic, ensuring non-list collections
and non-dictionary rows are safely ignored without crashing. Update
core/wren/tests/unit/test_check_descriptions_guards.py to cover
validate_manifest through its public entry point with malformed views and
non-list view collections.

---

Nitpick comments:
In `@core/wren/tests/unit/test_check_descriptions_guards.py`:
- Around line 4-23: Add regression coverage through the public validate_manifest
path rather than calling _check_descriptions directly. Include malformed
manifests with a non-dictionary view and non-list models and views, and assert
validation completes safely with the expected result; preserve coverage for
malformed model and column entries where applicable.
🪄 Autofix (Beta)

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: ed80ee3f-e825-4bcc-85ff-af5dd8450012

📥 Commits

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

📒 Files selected for processing (2)
  • core/wren/src/wren/context.py
  • core/wren/tests/unit/test_check_descriptions_guards.py

Comment on lines +1591 to +1596
views = manifest.get("views", []) or []
if not isinstance(views, list):
views = []
for view in views:
if not isinstance(view, dict):
continue

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.

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Malformed view rows can still crash the public validator.

The helper-level guards are correct, but validate_manifest processes raw views before reaching _check_descriptions. Fix the public dry-plan path and add regression coverage through that entry point.

  • core/wren/src/wren/context.py#L1591-L1596: normalize/filter malformed views before dry-planning.
  • core/wren/tests/unit/test_check_descriptions_guards.py#L4-L23: exercise validate_manifest, including malformed views and non-list collections.
📍 Affects 2 files
  • core/wren/src/wren/context.py#L1591-L1596 (this comment)
  • core/wren/tests/unit/test_check_descriptions_guards.py#L4-L23
🤖 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/src/wren/context.py` around lines 1591 - 1596, Normalize and filter
raw view entries in validate_manifest before the dry-planning logic, ensuring
non-list collections and non-dictionary rows are safely ignored without
crashing. Update core/wren/tests/unit/test_check_descriptions_guards.py to cover
validate_manifest through its public entry point with malformed views and
non-list view collections.

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