Dashboards: Fix issue causing crashes when saving new dashboard #77620
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.
Maybe "avoids issue" is a better title. The underlying issue is here:
grafana/public/app/features/dashboard/components/SaveDashboard/SaveDashboardErrorProxy.tsx
Lines 32 to 36 in d624a5d
Specifically line 34 where
error.isHandled
is set totrue
.It seems like what happens is:
DashboardPrompt
onHistoryBlock
function is called.hasChanges(dashboard, original)
is called, but at this stageoriginal
still hasversion
0, whiledashboard
hasversion
1. Note that there is code inDashboardPrompt
to updateoriginal
when aDashboardSavedEvent
is emitted, but I guesshasChanges
gets executed firstSaveDashboardErrorProxy
occurs, causing the crash.So with this PR the issue is sort of avoided by saying "ignore changes if all we're changing is a dashboard that hasn't been saved yet", but I guess a "real" fix would figure out how to update
original
inDashboardPrompt
before it looks for unsaved changes.Closes #77593