Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError: Cannot destructure property 'name' of '{}' as it is null. #2285

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

danielevalverde
Copy link
Contributor

Description

Avoid trying to destructure the prop of null

References: 5510

How to test?

Running unit tests and manually

Checklist

Comment on lines -121 to +122
media_cluster_origin_user: { name: user } = {},
},
media_cluster_origin_user: user = {},
} = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment] (non-blocker) I'm not a fan of this nested destructuring, but it works. Just a personal preference, I guess... 🤷

Comment on lines 112 to 116
media_cluster_origin_user: { name: user } = {},
media_cluster_origin_user: user = {},
media_cluster_relationship: mediaClusterRelationship,
},
}) => {
const { icon, message } = getIconAndMessage(origin, mediaClusterRelationship, user, originTimestamp);
const { icon, message } = getIconAndMessage(origin, mediaClusterRelationship, user?.name, originTimestamp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment] (non-blocker) If user is being assigned an empty object by default then the safe navigation operator shouldn't be necessary, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the unnecessary safe operator, @amoedoamorim 🫡

@danielevalverde danielevalverde merged commit cd73ed7 into develop Feb 7, 2025
11 checks passed
danielevalverde added a commit that referenced this pull request Feb 7, 2025
…ll. (#2285)

* Fix TypeError: Cannot destructure property 'name' of '{}' as it is null.

* remove unecessary safe operator
@danielevalverde danielevalverde deleted the fix/CV2-5510-sentry-error branch February 12, 2025 15:07
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.

2 participants