Repository navigation
fix(semantic-layers): show per-view errors when adding semantic views - #45524
aminghadersohi merged 4 commits into
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
CodeAnt PR Risk: Low Risk
Assessed commit: |
fitzee
left a comment
There was a problem hiding this comment.
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):
- 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. - non-blocking: errors persist after the source location changes.
- nit: failure count undercounts unnamed errors.
- 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 && ( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
aminghadersohi
left a comment
There was a problem hiding this comment.
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.
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:
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_LAYERSenabled: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
SEMANTIC_LAYERS