Skip to content

fix(dashboard): suppress favorite status error toast on 404#41402

Open
sadpandajoe wants to merge 3 commits into
masterfrom
fix-favorite-status-404-toast
Open

fix(dashboard): suppress favorite status error toast on 404#41402
sadpandajoe wants to merge 3 commits into
masterfrom
fix-favorite-status-404-toast

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

SUMMARY

When a non-owner user opens a draft dashboard by direct URL, the GET /api/v1/dashboard/favorite_status/ endpoint correctly returns 404 (draft dashboard visibility is owner/admin-only at the API layer). However, fetchFaveStar's .catch handler treated every error uniformly and surfaced a danger toast: "There was an issue fetching the favorite status of this dashboard."

A 404 here means "favorite status isn't available to this user" — it is not an error worth alarming the user about. This also covers the case where a dashboard is deleted after navigation began.

Fix: In fetchFaveStar's .catch, use the already-imported getClientErrorObject helper to extract the response status. If status === 404, return silently instead of dispatching the danger toast. Non-404 errors (network failures, 500s) continue to toast when the dashboard ID still matches, preserving the existing currentId === id race-condition guard.

Related: #33007 (closed unmerged) addressed the same symptom for the deleted-dashboard case. This PR covers both the draft-non-owner case and the deleted case with the same 404 check.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: Non-owner loads a draft dashboard → red danger toast appears on load.
After: No toast. The 404 from favorite_status is silently swallowed.

TESTING INSTRUCTIONS

  1. As an admin, create a dashboard and leave it in draft (unpublished) state.
  2. As a non-admin user who is NOT the dashboard owner, navigate directly to the dashboard URL.
  3. Before this fix: a red danger toast "There was an issue fetching the favorite status of this dashboard." appears.
  4. After this fix: no toast appears.
  5. Verify that genuine network errors (e.g. disconnect) still produce the toast on a published dashboard.

Automated: npm run test -- src/dashboard/actions/dashboardState.test.ts — the new test 'does NOT dispatch a danger toast on 404 error when the dashboard ID still matches' covers the fix, and the existing 'dispatches a danger toast on error when the dashboard ID still matches' (non-404) confirms non-404 errors still toast.

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

When a non-owner user opens a draft dashboard by direct URL, the
favorite_status API correctly returns 404 (draft visibility is
owner/admin-only). The frontend was treating all errors the same and
surfacing a danger toast. A 404 here means "favorite status isn't
available for this user" and should be swallowed silently. This also
covers the case where a dashboard is deleted after navigation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.37%. Comparing base (d6ede99) to head (0b1628f).
⚠️ Report is 53 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #41402   +/-   ##
=======================================
  Coverage   64.37%   64.37%           
=======================================
  Files        2653     2653           
  Lines      145152   145154    +2     
  Branches    33491    33492    +1     
=======================================
+ Hits        93446    93448    +2     
  Misses      50014    50014           
  Partials     1692     1692           
Flag Coverage Δ
javascript 68.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.

Replace the getClientErrorObject async call with an instanceof Response
type guard. This is type-safe (Response.status is a typed property) and
matches the runtime rejection shape from SupersetClient's parseResponse.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

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

Copilot AI 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.

Pull request overview

Suppresses the “favorite status” danger toast when the favorite_status API call returns a 404 (e.g., non-owner viewing a draft dashboard via direct URL, or a dashboard being deleted during navigation), while preserving the existing guard that prevents stale-error toasts after navigation.

Changes:

  • Update fetchFaveStar to silently swallow 404 responses instead of dispatching a danger toast.
  • Add a unit test ensuring no toast is dispatched for a 404 when the dashboard ID still matches.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
superset-frontend/src/dashboard/actions/dashboardState.ts Swallows 404 errors in fetchFaveStar to avoid alarming users when favorite status is legitimately unavailable.
superset-frontend/src/dashboard/actions/dashboardState.test.ts Adds regression coverage to confirm 404s do not dispatch a danger toast.

Ensures a 500 Response error still dispatches the danger toast,
preventing a future mutation from silently swallowing all Response
errors by dropping the status === 404 condition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sadpandajoe sadpandajoe marked this pull request as ready for review June 25, 2026 18:46
@dosubot dosubot Bot added change:frontend Requires changing the frontend dashboard:error Related to Dashboard errors labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dashboard:error Related to Dashboard errors review:draft size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants