Snowman.tokenURI() checks if (ownerOf(tokenId) == address(0)) and reverts with a custom error ERC721Metadata__URI_QueryFor_NonExistentToken. But OpenZeppelin's ERC721 ownerOf() already reverts with ERC721NonexistentToken for tokens that don't exist, so the custom check is never reached. The custom error is dead code.
OpenZeppelin ERC721 (v5.x) ownerOf() implementation:
The _requireOwned function reverts before returning address(0), so the custom check in tokenURI never evaluates to true. The ERC721Metadata__URI_QueryFor_NonExistentToken error is declared but can never be thrown.
Likelihood:
The dead code exists in every deployment.
Impact:
No security impact. The function still reverts for non-existent tokens — just with OpenZeppelin's error instead of the custom one. External integrations that catch ERC721Metadata__URI_QueryFor_NonExistentToken will never see it; they need to catch ERC721NonexistentToken instead.
Remove the unreachable check or replace ownerOf with a direct storage lookup:
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.