Skip to content

fix(mcp): skip non-list relationship models in describe_model - #2608

Closed
Bartok9 wants to merge 1 commit into
Canner:mainfrom
Bartok9:fix/mcp-rel-models-list
Closed

Bartok9 wants to merge 1 commit into
Canner:mainfrom
Bartok9:fix/mcp-rel-models-list

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

describe_model only matches relationships when models is a real list, so a string value cannot substring-match a model name.

Motivation

Related to #2590. "orders" in "orders_customers" is True in Python — non-list models would attach junk relationships.

Real behavior proof

pytest tests/unit/test_mcp_server.py::test_describe_model_skips_non_list_relationship_models -q
# 1 passed

Test plan

  • string models skipped; valid list kept

Summary by CodeRabbit

  • Bug Fixes

    • Improved model relationship details to ignore malformed relationship data.
    • Prevented incorrect relationship matches caused by string values being interpreted as model lists.
  • Tests

    • Added coverage to verify that only valid, list-based model relationships are displayed.

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

coderabbitai Bot commented Jul 28, 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: 36b4ac01-835b-4431-a967-b398538492d8

📥 Commits

Reviewing files that changed from the base of the PR and between a93184d and d9930bb.

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

Walkthrough

describe_model now defensively filters relationship data by shape and list-based model membership, with a unit test covering string-versus-list behavior.

Changes

Relationship matching

Layer / File(s) Summary
Validated relationship filtering
core/wren/src/wren/mcp_server.py, core/wren/tests/unit/test_mcp_server.py
describe_model skips non-dictionary relationships and non-list models fields, while the regression test verifies only valid list-based matches are returned.

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

Possibly related PRs

Suggested reviewers: annasusu

Poem

I’m a bunny guarding lists,
No stringy match escapes my twists.
Good relationships hop right through,
Bad shapes get a gentle “shoo!”
Tests bloom bright in the morning dew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main fix to skip non-list relationship models in describe_model.
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.

@Bartok9

Bartok9 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing per @goldmedal on #2613/#2607: relationships hardening belongs in one context.py PR matching 9bdae39 (#2604).

Superseded by #2613 (load + validate raw YAML). Downstream consumer re-guards are redundant once context normalizes list[dict].

@Bartok9 Bartok9 closed this Aug 7, 2026
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