Fix: Handle undefined tours property (Issue #25287) #25290
+11
−0
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.
What does it do?
This fix adds defensive checks to prevent runtime errors when the tours property is undefined or missing in the guided tour state. The changes add null/undefined guards in two components:
Step.tsx (DefaultActions component): Added a safety check that returns null if state.tours or the specific tour (state.tours[tourName]) is undefined before attempting to access currentStep.
Tours.tsx (GuidedTourTooltipImpl component): Added a safety check that renders children without the tooltip wrapper if state.tours or the specific tour is undefined, allowing the page to function normally without the guided tour.
Why is it needed?
This solves Issue #25287 where the application crashes with:
Cannot read properties of undefined (reading '[tourName]')This error occurs when:
Without these checks, attempting to access state.tours[tourName].currentStep throws an error that breaks the entire admin interface. These defensive checks ensure graceful degradation - if the guided tour data is unavailable, the UI continues to work without the tour functionality.
How to test it?
Test Case 1 - Simulate corrupted state:
Test Case 2 - Normal flow:
Verification Path:
Related issue(s)/PR(s)
Fixes #25287