Skip to content

fix(semantic-layers): show per-view errors when adding semantic views - #45524

Merged
aminghadersohi merged 4 commits into
apache:masterfrom
mikebridge:sc-127446-semantic-view-modal-errors
Oct 20, 2026
Merged

aminghadersohi merged 4 commits into
apache:masterfrom
mikebridge:sc-127446-semantic-view-modal-errors

Conversation

@mikebridge

Copy link
Copy Markdown
Member

SUMMARY

The Add Semantic View modal now shows which views could not be created and why, without losing track of views that were created successfully.

What users saw: an all-failed request showed only a generic toast. A partially successful request listed failed names but omitted the server's validation messages.

Why: the API returns per-view errors in both its 201 partial-success and 422 all-failed responses. The modal did not read the rejected 422 body or display the per-view details.

What this changes:

  • Display each failed view's name and validation message inline, including field-error mappings, as escaped text.
  • Keep the modal open for failures. Mark confirmed successes as already added, refresh the underlying list, and exclude those successes from the next retry.
  • Keep all-success behavior unchanged: report success and close.
  • Use a generic fallback for malformed responses and transport failures; do not display raw transport exception messages.
  • Ignore save responses belonging to a closed modal.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: failure toast without the validation details; successful items could remain selected after a partial result.

After: inline per-view errors and a retry selection containing only views that were not confirmed created.

No screenshots captured: application services were not started. Rendered feedback and retry behavior are covered by RTL tests.

TESTING INSTRUCTIONS

With SEMANTIC_LAYERS enabled:

  1. Open Add Semantic View and select multiple views.
  2. Make one view fail server validation while another succeeds. Confirm the successful view is marked already added, the error includes the failed view name and message, and the modal stays open.
  3. Retry and confirm only the failed view is submitted.
  4. Exercise an all-failed request, then an all-success request. Confirm errors remain visible for the former and the modal closes for the latter.

Automated: the touched AddSemanticViewModal Jest/RTL suite covers all-failed 422, mixed 201, all-success, malformed responses, transport failures, text escaping, retry exclusion and a late response after close/reopen. Changed-file hooks include targeted TypeScript checking.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SEMANTIC_LAYERS
  • 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

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.83721% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.68%. Comparing base (c01e784) to head (6aee861).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...ntend/src/features/semanticViews/creationResult.ts 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45524      +/-   ##
==========================================
+ Coverage   83.66%   83.68%   +0.01%     
==========================================
  Files        3053     3054       +1     
  Lines      200788   200894     +106     
  Branches    46861    46909      +48     
==========================================
+ Hits       167995   168122     +127     
+ Misses      29544    29527      -17     
+ Partials     3249     3245       -4     
Flag Coverage Δ
hive 34.89% <ø> (-0.01%) ⬇️
javascript 79.40% <98.83%> (+0.02%) ⬆️
mysql 52.85% <ø> (+<0.01%) ⬆️
postgres 52.86% <ø> (+<0.01%) ⬆️
presto 36.65% <ø> (-0.01%) ⬇️
python 87.20% <ø> (+0.01%) ⬆️
sqlite 52.62% <ø> (+<0.01%) ⬆️
unit 81.41% <ø> (+0.02%) ⬆️

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.

Bring in apache master ad30c89 without rebasing. Add the two extracted modal error messages and remove the obsolete count-only entry so the Babel drift gate matches source.
@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Oct 20, 2026
@mikebridge
mikebridge marked this pull request as ready for review October 20, 2026 17:46
@codeant-ai-for-open-source

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

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 6aee861628c9

@fitzee fitzee 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 with non-blocking issues.

Partial-success semantics are represented correctly: the backend commits each view in its own CreateSemanticViewCommand transaction (201 if any created, 422 if none), and the modal now marks created views as added, refreshes the list, and resubmits only the failures. Per-view messages come from fixed, translated command-layer strings or Marshmallow field errors and render as escaped text, so no driver/SQL detail reaches the browser. No API/schema change.

Findings (inline):

  1. non-blocking: closing the modal while a save is in flight now suppresses onSuccess, so views that were created leave the dataset list stale with no feedback.
  2. non-blocking: errors persist after the source location changes.
  3. nit: failure count undercounts unnamed errors.
  4. nit: unbounded error list height.

Outside the diff (pre-existing, but now user-visible): the most common failure, a view that already exists, shows only "Semantic view could not be created." validate() raises ValueError("Semantic view ... already exists ..."), @transaction(on_error=...) catches ValueError and re-raises SemanticViewCreateFailedError() with no args, so the specific message is dropped. Raising SemanticViewInvalidError(_("...already exists...")) there would surface a useful message through this new UI.

New tests fail against the base modal (6 of 6 targeted cases) and pass with the change; full AddSemanticViewModal.test.tsx suite passes (40/40). CI green.

Hosted test steps: with SEMANTIC_LAYERS on, Datasets -> + -> Semantic view, select two views where one already exists under the same configuration (add it once first, then reselect after changing the config back) and confirm the inline error; then start an add of several views and press Cancel before it returns, reopen, and check whether the list shows the new datasets.

}
body = await error.json();
}
if (gen !== fetchGenRef.current) return;

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.

non-blocking: Cancel/X stay enabled during save (StandardModal only disables the primary button), and closing bumps fetchGenRef, so this early return drops a response whose views were already committed server-side. Before this change the base code still called onSuccess()/toast after close; now the dataset list is not refreshed and the user gets no confirmation that anything was created (the new "closed and reopened" test asserts exactly this). Suggest skipping only the local state updates on a stale generation, but still calling onSuccess() (and the success toast) when created.length > 0.

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.

Fixed in 6aee861. A completed creation still refreshes the dataset list and reports success after the modal closes; the generation guard only prevents stale modal-local updates. The close/reopen regression test pins both sides.

saveLoading={saving}
>
<ModalContent>
{creationErrors.length > 0 && (

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.

non-blocking: creationErrors is cleared on layer change, close, and save, but not in handleRuntimeFormChange. After a partial failure, changing the source location (e.g. a different schema) replaces the views list while the alert still reports failures for views from the previous configuration. Clearing it when runtime data changes (or when the views list is refetched) avoids stale errors.

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.

Fixed in 6aee861. An actual runtime configuration change clears the previous creation errors; an unchanged form notification does not. Added a rendered-form regression for changing configuration after a failed save.

showIcon
message={t('Some semantic views could not be added')}
description={
<List

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.

nit: no height bound. With a large batch failing (e.g. layer unreachable, 100 selected views) the alert pushes the form far down the modal, and the toast concatenates all 100 names. A max-height + overflow-y: auto on the list, and truncating the toast name list ("a, b, c and 97 more"), would keep it usable.

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.

Fixed in 6aee861. The details are in a bounded, keyboard-scrollable region. Batches over three failures get a count-only toast, with every name and detail retained in the list. Added a 100-failure case.

? t(
'%s semantic view(s) failed to add: %s',
errors.length,
failedNames.length,

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.

nit: switching from errors.length to failedNames.length undercounts when the server returns an error without a name (the API emits view_data.get("name"), which is None for a schema-invalid entry): two failures render as "1 semantic view(s) failed to add: customers". Counting server errors separately from the synthetic generic entry keeps the number accurate.

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.

Fixed in 6aee861. The count comes from server error records, including unnamed ones, rather than the names shown in the toast. Synthetic malformed-response feedback is excluded. Added unnamed and mixed named/unnamed cases; all 44 modal tests pass.

@netlify

netlify Bot commented Oct 20, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 6aee861
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ad7ea6fcbef5ab600a5edaf
😎 Deploy Preview https://deploy-preview-45524--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.

@aminghadersohi
aminghadersohi self-requested a review October 20, 2026 22:59

@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 6aee861. Per-view errors are parsed for both the 201 partial-success and 422 all-failed responses, created views are dropped from the selection, and the four earlier threads are fixed with tests. CI green.

@aminghadersohi
aminghadersohi merged commit 0f376ba into apache:master Oct 20, 2026
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n Namespace | Anything related to localization size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants