Conversation
…ore duplication Prebuilt dashboards reference other prebuilt dashboards via linkedDashboards with placeholder dashboardId '-1'. During duplication from list/grid views, these placeholders were sent directly to the backend, causing failures. Extract shared pure utilities from usePopulateLinkedDashboards and add an async resolver (resolveLinkedDashboardIds) that fetches real IDs via TanStack queryClient.fetchQuery before cloning. Unresolved linked dashboards are dropped to avoid sending invalid '-1' IDs. DAIN-1300
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Loading state starts after resolver request
- Moved
setIsLoading(true)to the start of the duplication try-block so loading is active during linked-dashboard ID resolution and the button stays disabled throughout the async flow.
- Moved
Or push these changes by commenting:
@cursor push 6f48b888bd
Preview (6f48b888bd)
diff --git a/static/app/views/dashboards/hooks/useDuplicateDashboard.tsx b/static/app/views/dashboards/hooks/useDuplicateDashboard.tsx
--- a/static/app/views/dashboards/hooks/useDuplicateDashboard.tsx
+++ b/static/app/views/dashboards/hooks/useDuplicateDashboard.tsx
@@ -74,6 +74,7 @@
);
}
try {
+ setIsLoading(true);
const dashboardDetail = await resolveLinkedDashboardIds({
queryClient,
orgSlug: organization.slug,
@@ -83,7 +84,6 @@
delete newDashboard.prebuiltId;
newDashboard.title = `${newDashboard.title} copy`;
newDashboard.widgets.map(widget => (widget.id = undefined));
- setIsLoading(true);
const copiedDashboard = await createDashboard(
api,
organization.slug,This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Prebuilt dashboards reference other prebuilt dashboards via
linkedDashboardswith placeholderdashboardId: '-1'. During duplication from list/grid views, these placeholders were sent directly to the backend, causing failures.Extracts shared pure utilities (
getLinkedDashboardPrebuiltIds,replacePlaceholderLinkedDashboardIds) from the existingusePopulateLinkedDashboardshook and adds an async resolver (resolveLinkedDashboardIds) that fetches real IDs via TanStackqueryClient.fetchQuerybefore cloning. Unresolved linked dashboards are dropped to avoid sending invalid-1IDs.The resolver shares a
makeDashboardsQueryKeyhelper with the existing hook to keep query key construction consistent.This creates a bit of duplication with the code that resolves prebuilt IDs for displaying the pre-built dashboard, but that whole layer will need a re-look anyway. I filed a separate ticket for that: https://linear.app/getsentry/issue/DAIN-1341/consolidate-dashboards-data-fetching-code
DAIN-1300