Skip to content

fix(semantic-layer): classify provider errors in value suggestions - #45147

Merged
aminghadersohi merged 29 commits into
apache:masterfrom
mikebridge:sc-125622-provider-rejections-values-async
Oct 15, 2026
Merged

aminghadersohi merged 29 commits into
apache:masterfrom
mikebridge:sc-125622-provider-rejections-values-async

Conversation

@mikebridge

Copy link
Copy Markdown
Member

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

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)
    • 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

mikebridge and others added 9 commits October 8, 2026 15:46
…nd log unknown codes

Document that get_values is outside the rejection contract because value
search retries without its filter, and that async chart data shows the
generic failure for a typed rejection. Log an unknown rejection code at
warning level before it normalizes to INVALID_QUERY.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stion errors

The SDK docstring still described value search as best-effort with an
unfiltered retry. Value suggestions now classify typed rejections as client
errors and unclassified failures as server errors, and never retry without
the search filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi this is the follow-up to your review on #45110: value suggestions and the async chart path now use #45110's translator, so rejections are 4xx and faults stay 5xx. Stacked on #45110, so only the top two commits are new until it merges.

@github-actions github-actions Bot added i18n Namespace | Anything related to localization api Related to the REST API doc Namespace | Anything related to documentation labels Oct 9, 2026
@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7284a82
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6acfcfe0b99d3c29ce18dd1d
😎 Deploy Preview https://deploy-preview-45147--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.36%. Comparing base (b411454) to head (7284a82).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45147      +/-   ##
==========================================
+ Coverage   83.33%   83.36%   +0.02%     
==========================================
  Files        3040     3045       +5     
  Lines      198611   199253     +642     
  Branches    46346    46356      +10     
==========================================
+ Hits       165511   166098     +587     
- Misses      29876    29931      +55     
  Partials     3224     3224              
Flag Coverage Δ
hive 34.98% <30.00%> (+<0.01%) ⬆️
javascript 78.97% <100.00%> (+<0.01%) ⬆️
mysql 53.00% <35.00%> (+<0.01%) ⬆️
postgres 53.00% <35.00%> (+<0.01%) ⬆️
presto 36.74% <30.00%> (+<0.01%) ⬆️
python 86.92% <100.00%> (+<0.01%) ⬆️
sqlite 52.76% <35.00%> (+<0.01%) ⬆️
superset-extensions-cli 91.24% <ø> (?)
unit 80.91% <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.

@mikebridge
mikebridge marked this pull request as ready for review October 9, 2026 16:28
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; value suggestions now classify provider errors without retrying after dropping the search filter.
  • Tests cover guest responses, cache behavior, provider faults and rejections, async failures, non-text suggestions, and manual value entry.

Assessed commit: 7284a82b142f

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 9, 2026
@github-actions github-actions Bot added requires:rebase Requires rebasing on top of current master and removed requires:rebase Requires rebasing on top of current master labels Oct 10, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 12, 2026
@mikebridge

Copy link
Copy Markdown
Member Author

Codex validation of CodeAnt’s completeness concern at 04b2ab7cc9eb: this is already handled, so no code change is needed.

provider_completeness() translates the SDK completeness signal into the host SemanticResultCompletenessError, which subclasses QueryObjectValidationError. The execution wrapper explicitly re-raises that class before its generic-fault handler, preserving completeness classification rather than converting it to a 500. Host completeness errors raised directly follow the same path.

I reran 17 existing regression cases covering core/host incomplete and unverified errors, HTTP 400 and guest sanitization, async failure reasons without success publication, and value-search/endpoint failures without retry or cache writes. All passed on the assessed head.

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

Hey @mikebridge, thanks for carrying this through to the values endpoint. I scoped this to your top two commits, with #45110's head as the base.

Not blocking. The classification itself holds up: I could not get provider text into a response body on either status, and the guest differential behaves as you describe it. My one real concern is what the new 400 looks like from the picker, left inline on models.py.

I ran the semantic_layers, datasource, charts, common, tasks and security unit suites against 04b2ab7c and they are green, and CI is green too.

Comment thread superset/semantic_layers/models.py Resolved
Comment thread superset/datasource/api.py Resolved

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

Reviewed at 8213a3d. CI is green, and locally the semantic_layers, datasource, charts, common and tasks unit suites pass (2388 tests; the one failure is caused by my environment). Both of the points I deferred from #45110 are now covered. Value suggestions go through execute_semantic_query with no unfiltered retry, and nothing is cached on failure. A worker rejection now stores the host message, so async charts show the same text as sync. @gabotorresruiz's inline points are addressed: the type guard is in, the WARNING names the view, dimension and code without the search text, and both statuses use the {"message": ...} envelope. Two things remain:

  1. The guard on models.py:573 is narrower than the host's own idea of a string column (see the inline comment).
  2. The picker still hides the new 400. isSuggestionsOutage in AdhocFilterEditPopoverSimpleTabContent/index.tsx:93-96 only flags status >= 500. A string dimension whose provider rejects LIKE used to get the bounded page from the unfiltered retry on master. It now gets an empty list with the "Type a value here" placeholder, and the host guidance in the 400 body is never shown. Each keystroke also re-queries, so that is one 400 and one WARNING per keystroke. Either show the 400 message as helper text, or say in UPDATING that the frontend half is a follow-up.

Also, for non-string dimensions the hint at index.tsx:557 ("Type to search all of them") and the q description in datasource/api.py:160-162 ("only values containing it are returned") are no longer true. Typing now only filters the loaded page in the browser.

Comment thread superset/semantic_layers/models.py Resolved

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

Re-checked at 51c283b: only merges since my last review, and the suites pass locally (2405). Both open items still apply: the string/large_string guard in the models.py:576 thread, and the picker hiding the new 400.

@mikebridge

Copy link
Copy Markdown
Member Author

Codex follow-up to the picker point in Amin’s review: this is now fixed rather than left as a frontend follow-up. Semantic-view 400s show the backend’s sanitized guidance through getClientErrorObject, with a generic suggestions note if guidance is empty. Manual values remain available. SQL-dataset 400 behavior is unchanged.

The request guard runs after the asynchronous body parse, so a delayed old rejection cannot replace a newer successful search. New Jest cases cover guidance/manual entry, the bounded-page hint, and that delayed-body race; all 53 component cases pass.

The semantic truncation hint no longer promises whole-column search, and the API q description distinguishes text search from bounded non-text semantic suggestions. String-view and dictionary text narrowing is fixed too. Backend/core/async checks pass all 983 cases; branch-wide hooks and independent Claude review pass. #45110 is unchanged; no restack was needed.

Pushed in 1347e8348d.

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

Both open items from my last review are fixed at 82ca0f8 (the string-view/dictionary guard and the picker showing the 400), and CI is green. The only blocker is a conflict with master's #45109 in 5 files.

@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi the conflict with #45109 is resolved in bc4c99a (master merged into #45110 first, then into this branch; both sides of the five conflicting hunks kept, no feature changes). Ready for your re-look.

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

Approving at bc4c99a: the conflict resolution against #45109 keeps both sides in all five files, the new UPDATING/docs status claims match the code, both of my earlier findings stay fixed, and CI is green on every leg.

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

Thanks @mikebridge, both of my points are closed. The type guard discriminates rather than just switching narrowing off, the rejection path logs the view, the dimension and the code with no search text, and all four error branches on that route now answer {"message": ...}, so the docstring and the code agree. Teaching the picker about the 400 is more than I asked for.

I ran the semantic_layers, datasource, charts, common, tasks and explore unit suites and the picker jest file at c8af2255, and checked your new cases against the pre-fix code. CI is green here apart from actions-timeline.

The only thing in the way is the conflict, and of the two files one is UPDATING.md and the other is #45110's mapper.py against master's #45109, so neither is new work on this branch. One small question inline.

: optionsTruncated
? props.datasource?.type === 'semantic_view'
? t(
'Only the first %s values are listed. Enter a value manually if it is not listed.',

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.

Just a small NIT: this drops the search promise for every semantic dimension, including the string ones where the LIKE still reaches the provider, so a text column's picker now reads as if typing only filters the loaded page.

Is that deliberate because type_generic cannot tell the frontend whether the backend will narrow (get_column_type reports STRING for binary and list too, and those are not narrowed), or would splitting on the generic type here be worth it? Happy either way, I might be missing something.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex verification at e4e75cff63: yes, this conservative wording is deliberate. The values path sends LIKE for Arrow string, large_string and string_view (including dictionaries with those value types). Binary and list dimensions do not receive LIKE. The metadata sent to this picker reports type_generic=STRING for all of those, including dictionary, which also does not receive LIKE, so splitting on the generic type would promise server-side search for dimensions where the backend only returns the bounded page.

Text dimensions still send q and narrow at the provider; the hint does not change that behavior. I have left the code unchanged. The follow-up is to expose an explicit per-column search capability derived from the same backend predicate, then use it to restore the text-specific hint with text/binary/list/dictionary tests. Raw column.type is an Arrow display string, so I would avoid making the frontend duplicate that parser and type policy. Existing type/narrowing and picker-hint checks passed; no new commit for this reply.

@mikebridge

Copy link
Copy Markdown
Member Author

Codex update: merged the refreshed #45110 parent and master. In this commit, UPDATING.md now has one titled “Semantic provider error handling” entry covering chart queries and value suggestions, replacing the separate values bullet. It preserves typed rejection 400 guidance, generic provider-fault 500 responses, the former timeout/DB/template statuses, and the host-validation/worker-control exception caveat; it also states that failed narrowed searches do not retry broadly and manual entry remains available. @aminghadersohi, please re-look at the consolidated wording. Focused tests, picker tests and hooks passed, with independent Claude review of the cache merge.

@aminghadersohi

Copy link
Copy Markdown
Contributor

@mikebridge this now conflicts with master after the merges of #45110 and #44452. Once you resolve the conflict and CI is green, I'll merge it.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 14, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 14, 2026
@aminghadersohi
aminghadersohi merged commit 72bfc41 into apache:master Oct 15, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API doc Namespace | Anything related to documentation i18n Namespace | Anything related to localization size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants