Skip to content

fix: show the server's error message in the publish toggle and user info toasts - #44238

Merged
rusackas merged 3 commits into
apache:masterfrom
verdier:fix/surface-server-error-in-publish-and-user-info-toasts
Sep 22, 2026
Merged

rusackas merged 3 commits into
apache:masterfrom
verdier:fix/surface-server-error-in-publish-and-user-info-toasts

Conversation

@verdier

@verdier verdier commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

When saving fails, the Draft/Published toggle in the dashboard header and the user info modal always show the same fixed toast ("You do not have permissions to edit this dashboard." / "Something went wrong while saving the user info"). The error message returned by the server is dropped. This matters for extensions that add server-side guards on these endpoints, since their explicit refusal never reaches the user, and for Superset's own errors, such as the validation errors of PUT /api/v1/me/. Both flows now show the error text from getClientErrorObject, as other dashboard actions already do. They keep the current toast when the response has no message, and the toggle also keeps it for the default Forbidden 403 body.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: always the fixed toast. After: the server's message, e.g. "Length must be between 1 and 64."

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- src/dashboard/actions/dashboardState.test.ts
npm run test -- src/features/userInfo/UserInfoModal.test.tsx
  1. Open your user info page, click "Edit user", set a first name longer than 64 characters and save. The toast reads "Length must be between 1 and 64." instead of "Something went wrong while saving the user info".
  2. Open a dashboard you can edit. In another session, remove your edit rights on it, then click the Draft/Published badge. The toast still reads "You do not have permissions to edit this dashboard."

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

@verdier
verdier force-pushed the fix/surface-server-error-in-publish-and-user-info-toasts branch from e318b80 to 7b321e5 Compare September 14, 2026 13:27
…nfo toasts

The dashboard Draft/Published toggle and the user info modal discarded the
failed response and always showed a fixed toast, so an explicit message
returned by the backend (a validation error, or a guard added by an
extension) never reached the user.

Both now show the error text read with `getClientErrorObject`, and keep
the current toast when the response carries no message.
@verdier
verdier force-pushed the fix/surface-server-error-in-publish-and-user-info-toasts branch from 7b321e5 to aa1f058 Compare September 14, 2026 13:30
@verdier
verdier marked this pull request as ready for review September 14, 2026 13:34
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. In the current implementation of UserInfoModal.tsx, the catch block handles the error by displaying a toast, but it does not prevent the FormModal from proceeding as if the operation were successful. Because the catch block resolves (it does not re-throw the error), the FormModal component likely interprets the completion of the onSave handler as a success, leading to the modal closing prematurely.

To resolve this, you should ensure that the onSave callback is only invoked when the operation succeeds. You can achieve this by moving the onSave() call inside the try block after the successful API response, ensuring it is not reached if an error occurs.

Would you like me to implement this fix for you, and would you like me to check and address the rest of the comments on this PR as well?

superset-frontend/src/features/userInfo/UserInfoModal.tsx

try {
      await SupersetClient.put({ ... });
      addSuccessToast(t('The user info update was successful'));
      onSave();
    } catch (response) {
      const { error } = await getClientErrorObject(response);
      addDangerToast(
        error || t('Something went wrong while saving the user info'),
      );
    }

@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.18%. Comparing base (24fe87e) to head (9ea5dd4).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44238   +/-   ##
=======================================
  Coverage   80.17%   80.18%           
=======================================
  Files        2925     2925           
  Lines      172679   172685    +6     
  Branches    40092    40096    +4     
=======================================
+ Hits       138452   138462   +10     
+ Misses      31630    31626    -4     
  Partials     2597     2597           
Flag Coverage Δ
javascript 75.67% <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.

@bito-code-review

bito-code-review Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3c37c4

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/dashboard/actions/dashboardState.ts - 1
    • Fragile Forbidden check · Line 280-282
      `message` is optional in `ClientErrorObject` and is only set when the body parses as JSON. For non-JSON error bodies `getClientErrorObject` returns `{...responseObject, error: ...}` with `message` undefined, so `message !== 'Forbidden'` is always true and the raw 'Forbidden' text is shown. Consider checking the always-populated `error` field instead: `error && error !== 'Forbidden' ? error : t(...)`.
Review Details
  • Files reviewed - 4 · Commit Range: aa1f058..051c83a
    • superset-frontend/src/dashboard/actions/dashboardState.test.ts
    • superset-frontend/src/dashboard/actions/dashboardState.ts
    • superset-frontend/src/features/userInfo/UserInfoModal.test.tsx
    • superset-frontend/src/features/userInfo/UserInfoModal.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Sep 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

@bito-code-review

bito-code-review Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d85240

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 051c83a..9ea5dd4
    • superset-frontend/src/dashboard/actions/dashboardState.test.ts
    • superset-frontend/src/dashboard/actions/dashboardState.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks for the tests covering both paths. Approving.

@rusackas
rusackas merged commit 0382c19 into apache:master Sep 22, 2026
83 checks passed
villebro pushed a commit that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants