Skip to content

fix(mcp): propagate semantic metric discovery refusals - #45905

Draft
mikebridge wants to merge 2 commits into
apache:masterfrom
mikebridge:sc-126718-mcp-refusal-propagation
Draft

mikebridge wants to merge 2 commits into
apache:masterfrom
mikebridge:sc-126718-mcp-refusal-propagation

Conversation

@mikebridge

Copy link
Copy Markdown
Contributor

SUMMARY

TL;DR: Metric discovery reports an access refusal instead of showing a misleading empty or incomplete catalog.

Background. MCP clients use list_metrics to find metrics across datasets and semantic views.

Problem. If a semantic view refused discovery while loading metrics or compatible dimensions, the per-view fallback swallowed that refusal and reported a successful result. Clients could mistake missing metrics for an empty catalog.

What changes. Typed security refusals reach the existing AccessDenied handler. If any visible view refuses discovery, an unscoped list_metrics call fails as a whole, including built-in dataset metrics; use dataset_id or view_id to scope the call to a source that does not refuse. Unexpected provider failures keep their warning and partial-result behavior. Tests cover scoped and unscoped discovery through streamable HTTP, plus refusal responses on both async chart-data HTTP paths. No SDK or /compatible behavior changes.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable: MCP and HTTP response behavior.

TESTING INSTRUCTIONS

Run pytest tests/unit_tests/mcp_service/semantic_layer/tool/test_list_metrics.py tests/unit_tests/semantic_layers/query_errors_test.py -q.

143 tests passed. Six discovery cases fail on the old code and pass with the fix. Both async HTTP cases fail when refusals are deliberately converted to 202 responses; the production async implementation is unchanged. Changed-file hooks pass.

HTTP tests use in-process transports and injected refusal exceptions. They do not require or validate a live provider, broker or worker.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SEMANTIC_LAYERS for semantic-view discovery
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.73%. Comparing base (9e4292e) to head (aba100c).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #45905   +/-   ##
=======================================
  Coverage   84.73%   84.73%           
=======================================
  Files        3069     3069           
  Lines      205771   205792   +21     
  Branches    48396    48399    +3     
=======================================
+ Hits       174354   174378   +24     
+ Misses      28123    28122    -1     
+ Partials     3294     3292    -2     
Flag Coverage Δ
hive 34.50% <0.00%> (-0.01%) ⬇️
mysql 52.60% <0.00%> (-0.01%) ⬇️
postgres 52.60% <0.00%> (-0.01%) ⬇️
presto 36.23% <0.00%> (-0.01%) ⬇️
python 87.76% <100.00%> (+<0.01%) ⬆️
sqlite 52.37% <0.00%> (-0.01%) ⬇️
unit 82.52% <100.00%> (+<0.01%) ⬆️

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant