mikebridge opened a new pull request, #45147:
URL: https://github.com/apache/superset/pull/45147
> **Stacked on #45110.** This branch includes #45110's commits. Until #45110
merges, only the top two commits are new here:
> - `fix(semantic-layer): classify provider failures in value suggestions`
> - `docs(semantic-layer): align get_values contract with classified
suggestion errors`
>
> I'll rebase onto master once #45110 lands.
### SUMMARY
Follow-up to #45110, which returns 4xx for provider validation errors on the
synchronous chart-data path. Review of #45110 pointed out two paths it didn't
cover. This PR handles both by reusing #45110's single translator
(`execute_semantic_query`), with no second mapping of codes to strings.
**Values endpoint** (`GET
/api/v1/datasource/<type>/<id>/column/<col>/values/`):
- `SemanticView.values_for_column` calls `get_values` through the shared
translator. Its signature is widened with a `ParamSpec` so it accepts the
provider's arguments.
- A typed `SemanticQueryRejectedError` returns **HTTP 400**, with the same
host-owned guidance as chart data.
- An unclassified provider fault returns **HTTP 500**, with generic text and
nothing from the provider.
- Embedded guests get the generic message in both cases, as on the
chart-data path.
- Completeness errors keep their HTTP 400 and fixed guidance.
- **A failed search no longer retries without its filter.** Before, any
failure of a filtered `get_values` call was logged and retried unfiltered,
which hid rejections from users. Failed results are never cached.
**Async chart path:** no production change was needed. With the real
`execute_chart_query` worker, the classified rejection or fault already reaches
the task failure with the same status and host text. This PR adds regression
coverage for every rejection code, plus faults, for guest and non-guest users.
**Provider contract:** the `get_values` docstring in `superset-core`, the
developer docs and `UPDATING.md` now describe this behavior. Use
`SemanticQueryRejectedError` only for positively identified input rejection,
for example a search filter the dimension can't apply. Leave other failures
unclassified.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable; this is an API status and error-text change. Before: a
provider rejection on value suggestions became a 500, or was silently retried
without the search filter. After: rejections return 400 with guidance, and
faults return 500 with generic text.
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/semantic_layers/values_endpoint_test.py \
tests/unit_tests/semantic_layers/query_errors_test.py \
tests/unit_tests/semantic_layers/models_test.py
```
- `values_endpoint_test.py`:
- every rejection code, with and without search, for guest and non-guest
users → 400 with the chart-data message, one provider call, no cache write;
- faults (`ValueError`, `RuntimeError`, `TimeoutError`) → 500 with generic
text.
- `query_errors_test.py`:
`test_async_provider_error_matches_sync_chart_error` runs the real async worker
and checks that it raises the same classified exception, with the same public
message, as the sync path.
- `models_test.py`: a failed search never retries without its filter.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] 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
Behavior change for semantic-layer providers: value search is no longer
best-effort, so a failed filtered `get_values` call surfaces instead of falling
back to the unfiltered page. This is noted in `UPDATING.md`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]