Skip to content

fix(mcp): set .embedded on update_dashboard test mocks#41499

Closed
rusackas wants to merge 1 commit into
masterfrom
fix/mcp-update-dashboard-embedded-mock
Closed

fix(mcp): set .embedded on update_dashboard test mocks#41499
rusackas wants to merge 1 commit into
masterfrom
fix/mcp-update-dashboard-embedded-mock

Conversation

@rusackas

@rusackas rusackas commented Jun 28, 2026

Copy link
Copy Markdown
Member

SUMMARY

Master's Python-Unit CI is red. Five tests in tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py fail with:

fastmcp.exceptions.ToolError: Error calling tool 'update_dashboard': 'Mock' object is not subscriptable

The cause is the shared dashboard_serializer in superset/mcp_service/dashboard/schemas.py. #41195 added:

embedded_uuid=str(dashboard.embedded[0].uuid) if dashboard.embedded else None,

That production code is fine: a real dashboard.embedded is an empty list when the dashboard isn't embedded, so the guard short-circuits. The problem is that update_dashboard routes through the same serializer, and the test mocks in test_update_dashboard.py never set .embedded. Mock hands back a truthy auto-Mock, the if dashboard.embedded guard passes, and dashboard.embedded[0] blows up. #41195 only updated the get_dashboard_info mocks in test_dashboard_tools.py, not these.

Fix is test-only: I set embedded = [] on the shared _mock_dashboard builder so it matches the not-embedded production case. No production code changes; the guard in schemas.py is correct as-is. I checked the sibling tool tests and they don't reach this serializer line, so nothing else needed touching.

References #41195.

BEFORE/AFTER

Before: Python-Unit red, 5 failures in test_update_dashboard.py.
After: pytest tests/unit_tests/mcp_service/dashboard/tool/ passes (117 passed locally).

TESTING INSTRUCTIONS

pytest tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Migration is atomic, supports rollback & is backwards-compatible
  • Confirm DB migration upgrade and downgrade tested
  • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

The shared dashboard_serializer change in #41195 added
embedded_uuid=str(dashboard.embedded[0].uuid) if dashboard.embedded else None.
Production is correct (real dashboard.embedded is an empty list when not
embedded), but update_dashboard flows through the same serializer and its
test mocks never set .embedded, so it was a truthy auto-Mock that passed
the guard and then failed to subscript, turning master's Python-Unit CI red
with "'Mock' object is not subscriptable". Setting embedded=[] on the shared
mock builder matches the not-embedded production case. Test-only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d0a400

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: d7f8c88..d7f8c88
    • tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.52%. Comparing base (97cb002) to head (d7f8c88).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41499      +/-   ##
==========================================
+ Coverage   63.95%   64.52%   +0.56%     
==========================================
  Files        2664     2664              
  Lines      146223   146223              
  Branches    33733    33733              
==========================================
+ Hits        93514    94347     +833     
+ Misses      50991    50158     -833     
  Partials     1718     1718              
Flag Coverage Δ
hive 39.22% <ø> (ø)
mysql 57.97% <ø> (ø)
postgres 58.03% <ø> (ø)
presto 40.80% <ø> (ø)
python 59.46% <ø> (+1.21%) ⬆️
sqlite 57.66% <ø> (ø)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hainenber

Copy link
Copy Markdown
Contributor

I approved this and an earlier PR from @nytai. I'll be merging the former due to FIFO. Thanks Evan!

@hainenber hainenber closed this Jun 28, 2026
@rusackas

Copy link
Copy Markdown
Member Author

Thanks! That makes TWO less PRs... a win in my book ;)

@hainenber hainenber deleted the fix/mcp-update-dashboard-embedded-mock branch June 29, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants