Skip to content

Conversation

@sargunesh25
Copy link

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:

  1. 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.

  2. 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:

  • The guided tour state is corrupted or not properly initialized
  • The tours data structure is missing from the state
  • Users have old/stale localStorage data
  • State hydration fails during initial load

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:

  1. Open browser DevTools → Application → Local Storage
  2. Find the key containing guided tour state
  3. Manually corrupt it by removing the tours property or setting it to undefined
  4. Refresh the admin panel
  5. Expected: Page loads normally without errors (previously would crash)

Test Case 2 - Normal flow:

  1. Clear browser cache and localStorage
  2. Navigate to the admin panel
  3. Interact with pages that trigger guided tours
  4. Expected: Guided tours work normally when state is properly initialized

Verification Path:

  1. Navigate to: /admin
  2. Monitor browser console for errors related to state.tours
  3. Verify the admin interface loads without crashes

Related issue(s)/PR(s)

Fixes #25287

@vercel
Copy link

vercel bot commented Jan 29, 2026

@sargunesh25 is attempting to deploy a commit to the Strapi Team on Vercel.

A member of the Team first needs to authorize it.

@strapi-cla
Copy link

strapi-cla commented Jan 29, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot
Copy link

dosubot bot commented Jan 29, 2026

Related Documentation

Checked 2 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of undefined (reading 'tours')

2 participants