Skip to content

Conversation

salimtb
Copy link
Contributor

@salimtb salimtb commented Mar 11, 2025

Explanation

This PR addresses an issue in NFT detection where the code attempts to destructure the imageOriginal property from the NFT token's metadata field. When metadata is null, this results in the runtime error:

"null is not an object (evaluating '(w=void 0===w?{}:w).imageOriginal')"

To fix the issue, the NFT detection logic has been updated to safely handle cases where metadata is null by providing a fallback (e.g., using an empty object or optional chaining). This prevents the error and ensures that NFT tokens without metadata are processed without causing a runtime exception.

References

Fixes: 12517

Changelog

@metamask/assets-controllers

  • FIXED: Resolved runtime error in NFT detection by safely handling null metadata during destructuring.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@salimtb salimtb marked this pull request as ready for review March 11, 2025 13:06
@salimtb salimtb requested a review from a team as a code owner March 11, 2025 13:06
@salimtb salimtb enabled auto-merge (squash) March 12, 2025 09:54
@salimtb salimtb merged commit 8a78cbb into main Mar 12, 2025
136 checks passed
@salimtb salimtb deleted the fix/nft-controller-metadata-null branch March 12, 2025 09:58
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.

[Sentry] TypeError: null is not an object (evaluating '(w=void 0===w?{}:w).imageOriginal')
3 participants