mikebridge opened a new pull request, #45359: URL: https://github.com/apache/superset/pull/45359
A compatibility request with a stale or misspelled metric or dimension used to succeed after silently dropping that selection. It now returns a 400 that names the unknown member. ### SUMMARY **Background.** Explore asks `/api/v1/datasource/<type>/<id>/compatible` which metrics and dimensions fit the current selection. MCP compatibility tools already reject unknown names through the shared name validator. **Problem.** The REST endpoint could return and cache an answer for a smaller selection than the caller sent, particularly after a provider member was renamed. **What this changes.** After datasource authorization and before cache lookup, the endpoint validates selected metric and dimension names with that same shared validator. Unknown names return a 400 naming each member. Known selections continue through the existing compatibility and cache path. The shared route applies the same validation to SQL datasets. Fixes [SC-126622](https://app.shortcut.com/preset/story/126622). ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF No UI change. Before, selecting `old_metric` after a provider rename could return 200 with compatibility computed as though it was absent. After, the REST response is 400 with `Unknown metric: 'old_metric'`. ### TESTING INSTRUCTIONS 1. With `SEMANTIC_LAYERS` enabled, POST to `/api/v1/datasource/semantic_view/<id>/compatible` using one selected metric or dimension that the view no longer exposes. Confirm a 400 names the unknown member; both kinds can be named in one response. 2. Repeat with valid selected names and confirm the normal 200 compatibility lists. Explore continues to treat a failed compatibility request as unverified and show unfiltered choices, as it does for other failures. 3. Run `python -m pytest tests/integration_tests/datasource/api_tests.py -q -k compatible_rejects_unknown` and `python -m pytest tests/unit_tests/mcp_service/semantic_layer/tool/test_compatibility_selection_validation.py tests/unit_tests/semantic_layers/models_test.py -q`. From `superset-frontend`, run `npx jest --runInBand --coverage=false --silent src/explore/actions/exploreActions.test.ts`. The new semantic-view test failed on master with `assert 200 == 400` and passes here. The focused Python set passed (200 tests, with four unrelated datasource-list tests excluded); the Explore action suite passed (11 tests). Changed-file pre-commit passed, including MyPy, Ruff, and Pylint. The four excluded datasource-list tests fail locally because this checkout's SQLite test schema lacks `semantic_layers.cache_version`; they do not exercise `/compatible`. ### ADDITIONAL INFORMATION - [x] Has associated issue: [SC-126622](https://app.shortcut.com/preset/story/126622) - [x] Required feature flags: `SEMANTIC_LAYERS` for semantic views (existing) - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] 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 Validation reads the view's live metric and dimension metadata even on a compatibility-result cache hit. This keeps a renamed member from being accepted solely because an earlier answer was cached; a review note records the potential metadata-read cost. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
