Repository navigation
fix(reports): open existing subscription instead of failing on duplicate - #45753
BrandanBurgess wants to merge 5 commits into
Conversation
Subscribing to a chart or dashboard the user already has a report for returns a 409 from /api/v1/report/subscribe. The report modal showed a generic "Failed to create report" error. On a 409 it now loads the existing subscription into the modal in edit mode and explains why. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gabotorresruiz
left a comment
There was a problem hiding this comment.
@BrandanBurgess thanks for picking this up from the discussion in #42922, nice fix! The duplicate path checks out for both charts and dashboards. I left one small non-blocking note inline.
CI note: the failing lanes are infrastructure (mostly a GitHub API rate limit during change detection), and because of that the frontend test and lint lanes were skipped. I ran the src/features/reports/ suites locally and they pass.
| 'You are already subscribed to this dashboard. Your existing report has been opened for editing.', | ||
| ), | ||
| ); | ||
| setCurrentReport({ isSubmitting: false }); |
There was a problem hiding this comment.
Not a blocker. The list endpoint behind fetchUISpecificReport doesn't return custom_width, so after this recovery the Screenshot width field keeps whatever was typed into the abandoned create form while every other field shows the existing report. Clicking Save then PUTs that width onto the existing subscription. Clearing it here keeps it out of the PUT, the same as opening the report from "Manage email report":
| setCurrentReport({ isSubmitting: false }); | |
| setCurrentReport({ isSubmitting: false, custom_width: undefined }); |
Typing a width before clicking Add in your first test would pin it.
There was a problem hiding this comment.
Thanks, I'm going to make this change as well!
There was a problem hiding this comment.
Pushed changes to address this
The report list endpoint does not return custom_width, so after recovering from a duplicate subscription the Screenshot width field kept the value typed into the abandoned create form, and saving would PUT it onto the existing report. Clear it, matching what opening via "Manage email report" does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45753 +/- ##
==========================================
- Coverage 84.70% 84.70% -0.01%
==========================================
Files 3069 3069
Lines 205610 205623 +13
Branches 48330 48338 +8
==========================================
+ Hits 174157 174167 +10
- Misses 28160 28163 +3
Partials 3293 3293
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:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e-subscription-redirect
SUMMARY
When a user tries to set up an email report for a chart or dashboard they are already subscribed to,
POST /api/v1/report/subscribereturns409 Resource already has an attached report.The report modal treated that like any other failure: a "Failed to create report" toast plus an error alert, leaving the user to find their existing subscription on the Alerts & Reports page.This usually happens when the header menu is out of date, e.g. the subscription was created in another tab, so the menu still offers "Set up an email report" instead of "Manage email report".
With this change, a 409 on the subscribe path:
subscribeReportfetchUISpecificReportlookup the header dropdown uses), which puts it in the Redux store, so the modal switches to edit mode with the existing report's settings and the header menu updates to "Manage email report"If the existing report can't be found (for example, the lookup fails), the modal falls back to the current error behaviour.
No backend change is needed: the 409 is already returned and covered by
tests/integration_tests/reports/api_tests.py.Based on the discussion in #42922.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: "Failed to create report" toast and error alert in the modal.
After: the modal reopens as "Edit email report" with the existing subscription loaded, plus an info toast.
TESTING INSTRUCTIONS
ALERT_REPORTSand open a dashboard in two tabs.Unit tests:
npm run test -- src/features/reports/ReportModalduplicate subscription opens the existing report for editingduplicate subscription shows the error when the existing report cannot be foundADDITIONAL INFORMATION
ALERT_REPORTS🤖 Generated with Claude Code