Fix TypeError in MasterbarLoggedIn.renderProfileMenu when user is null#108576
Draft
StevenDufresne wants to merge 1 commit intotrunkfrom
Draft
Fix TypeError in MasterbarLoggedIn.renderProfileMenu when user is null#108576StevenDufresne wants to merge 1 commit intotrunkfrom
StevenDufresne wants to merge 1 commit intotrunkfrom
Conversation
`getCurrentUser()` can return null before user data has loaded, causing a crash when `renderProfileMenu()` accesses `user.display_name`. Add a null guard to gracefully skip rendering the profile menu until the user object is available. Fixes CALYPSO-297Z Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Contributor
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
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.
Fixes CALYPSO-297Z
Proposed Changes
Why are these changes being made?
getCurrentUser() can return null before user data has finished loading from the Redux store. When this happens, renderProfileMenu() attempts to access user.display_name and user.username, which throws a TypeError: Cannot read properties of null (reading
'display_name').
This error has been tracked as https://a8c.sentry.io/issues/CALYPSO-297Z since March 2025.
The fix gracefully skips rendering the profile menu until the user object is available. This is safe because there is nothing meaningful to display without user data — the menu shows the user's display name, username, and gravatar, all of which require the user object.
Testing Instructions
Pre-merge Checklist