Skip to content

fix(mcp): harden list_cubes member arrays - #2617

Open
Bartok9 wants to merge 2 commits into
Canner:mainfrom
Bartok9:fix/mcp-list-cubes-member-guards
Open

fix(mcp): harden list_cubes member arrays#2617
Bartok9 wants to merge 2 commits into
Canner:mainfrom
Bartok9:fix/mcp-list-cubes-member-guards

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What failure does this repair?

MCP list_cubes raised AttributeError: 'str' object has no attribute 'get' when a cube's measures/dimensions/time_dimensions was non-list or held non-dict members. Repro: call the list_cubes tool against a manifest whose cube has "measures": ["revenue"] — name extraction called .get("name") on the string and the tool failed.

Summary

list_cubes now ignores invalid cube entries and extracts names only from valid dictionary members.

Verification

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

Duplicate check

Searched open/closed PRs; #2615 hardens related cube listing but not the member-array normalization in this path. No overlap.

list_cubes assumed cube members were always lists of dicts. Skip
non-dict cubes and member rows so malformed cube YAML cannot crash MCP.
@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

list_cubes now handles malformed cube and member structures defensively, while a unit test verifies filtering and name extraction behavior.

Changes

Cube enumeration robustness

Layer / File(s) Summary
Normalize cube members and validate malformed input
core/wren/src/wren/mcp_server.py, core/wren/tests/unit/test_mcp_server.py
list_cubes ignores invalid cube entries and extracts names only from valid dictionary members; the unit test covers malformed measures and mixed dimensions.

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

Possibly related PRs

  • Canner/WrenAI#2615: Related hardening of cube listing and tests for malformed cube members.

Poem

I hop through cubes, both neat and strange,
And skip the shapes that drift or change.
Valid names sparkle in my tray,
While malformed bits bounce away.
Tests thump softly—hip-hop, hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and accurately describes the main change: hardening list_cubes member array handling.
Description check ✅ Passed The description covers the required sections with a clear failure, summary, test verification, and duplicate check.
✨ 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.

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