Skip to content

fix(mcp): await ctx.info calls in update_dashboard tool#41920

Merged
aminghadersohi merged 4 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/fix-mcp-update-dashboard-unawaited-ctx-info
Jul 15, 2026
Merged

fix(mcp): await ctx.info calls in update_dashboard tool#41920
aminghadersohi merged 4 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/fix-mcp-update-dashboard-unawaited-ctx-info

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

update_dashboard in the MCP service called ctx.info(...) without await inside a sync tool function. fastmcp.Context.info is an async method, so these calls created unawaited coroutines and the log lines were silently dropped instead of being emitted.

Made the tool async and awaited both ctx.info calls, matching the pattern used by every other MCP tool in the service.

A repo-wide grep for the same pattern (sync def tool functions calling ctx.info/debug/warning/error without await) turned up no other occurrences.

BEFORE/AFTER

Before: the two ctx.info(...) calls in update_dashboard created coroutines that were never awaited or scheduled, so nothing was logged to the MCP client.
After: both calls are awaited and the log lines are emitted as expected.

TESTING INSTRUCTIONS

  • pytest tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py
  • Added test_ctx_info_is_awaited, which patches fastmcp.Context.info with an AsyncMock and asserts it is awaited exactly twice with the expected messages — this test fails without the fix.

ADDITIONAL INFORMATION

  • Has associated tests

Context.info is async; calling it without await inside the sync
update_dashboard tool created unawaited coroutines, silently dropping
the log lines. Make the tool async and await both calls, matching the
convention used by every other MCP tool.
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.79%. Comparing base (4dde4d2) to head (fe5b018).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...set/mcp_service/dashboard/tool/update_dashboard.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41920      +/-   ##
==========================================
- Coverage   64.80%   64.79%   -0.02%     
==========================================
  Files        2740     2739       -1     
  Lines      153135   152940     -195     
  Branches    35129    35044      -85     
==========================================
- Hits        99246    99101     -145     
+ Misses      51991    51938      -53     
- Partials     1898     1901       +3     
Flag Coverage Δ
hive 39.08% <33.33%> (ø)
mysql 58.03% <33.33%> (ø)
postgres 58.09% <33.33%> (-0.01%) ⬇️
presto 41.04% <33.33%> (ø)
python 59.47% <33.33%> (-0.01%) ⬇️
sqlite 57.69% <33.33%> (ø)
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.

@aminghadersohi
aminghadersohi marked this pull request as ready for review July 10, 2026 05:11
@aminghadersohi
aminghadersohi requested a review from Copilot July 10, 2026 05:11
@aminghadersohi
aminghadersohi requested a review from rusackas July 10, 2026 05:13

Copilot AI 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.

Pull request overview

This PR fixes missing MCP client log output from the update_dashboard tool by converting it to an async tool function and correctly awaiting fastmcp.Context.info(...) calls, preventing unawaited coroutine drops.

Changes:

  • Convert update_dashboard MCP tool to async def and await both ctx.info(...) calls so logs are emitted to the MCP client.
  • Add a unit test asserting that Context.info is actually awaited during an update_dashboard call (regression coverage for the unawaited-coroutine bug).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
superset/mcp_service/dashboard/tool/update_dashboard.py Makes the MCP tool async and awaits ctx.info so log lines are not silently dropped.
tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py Adds a regression test to ensure ctx.info is awaited when calling the MCP tool.

Comment thread tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py Outdated
@bito-code-review

Copy link
Copy Markdown
Contributor

The current test implementation is indeed brittle because it asserts an exact count of awaits (await_count == 2) and relies on positional indexing of the await_args_list. To make the test more robust while still verifying that the required log lines are awaited, you can iterate through the await_args_list and check for the presence of the expected messages, regardless of the total number of calls.

Here is a suggested update for the test logic:

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

# ... (previous test setup)
        assert mock_ctx_info.await_count >= 2
        awaited_messages = [call.args[0] for call in mock_ctx_info.await_args_list]
        assert any("Updating dashboard" in msg for msg in awaited_messages)
        assert any("updated" in msg for msg in awaited_messages)

@bito-code-review

bito-code-review Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d179a5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 2817088..2817088
    • superset/mcp_service/dashboard/tool/update_dashboard.py
    • 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

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bito-code-review

bito-code-review Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #119f91

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 2817088..a9b49f2
    • 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

@aminghadersohi
aminghadersohi requested review from rebenitez1802 and removed request for rusackas July 14, 2026 18:20

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

LGTM

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

LGTM

@aminghadersohi
aminghadersohi merged commit cec9afb into apache:master Jul 15, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants