fix: roundTo returns null for a null value instead of throwing - #9
Merged
Conversation
#7 made usd values null when the token has no exchange rate. roundTo unboxes its argument, so every caller that hands it a usd value directly started throwing a NullPointerException rather than rendering nothing: java.lang.NullPointerException at BaseMapper.roundTo(BaseMapper.java:124) at BaseMapper.roundTo(BaseMapper.java:128) at NFTService.getNFTDetail(NFTService.java:662) That is a live 500 on the nft detail page, for any nft whose template has a floor listing priced in FOOBAR, RDM or EASY - the page shows "Something went wrong". Rounding an unknown value yields an unknown value, so the guard belongs here rather than at each caller: there are more than twenty of them across several repositories and every one wants the same answer. The audit behind #7 covered buildPriceInfo and stopped there. It should have covered every caller of roundTo, since making a value nullable is only safe once everything that consumes it can take a null. Refs #7 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Live 500 on the NFT detail page.
https://soon.market/nft/4398046952294and.../4398046704949both show "Something went wrong":Cause
roundTounboxes its argument:That was harmless while every usd value was a number. #7 made them null when the token has no exchange rate, and every caller that hands a usd value straight to
roundTobegan throwing instead of rendering nothing.NFTService:662is one:So the detail page 500s for any NFT whose template has a floor listing priced in FOOBAR, RDM or EASY. That is why it looks scattered rather than affecting a whole category — it depends on the template's floor listing, not on the NFT itself.
Fix
Rounding an unknown value yields an unknown value. The guard belongs in
roundTo, not at each caller: there are 22 callers across 8 files insoon-market-apialone, plus more in the other consumers, and every one of them wants the same answer.What went wrong in #7
The audit behind #7 covered
buildPriceInfoand stopped there. Making a value nullable is only safe once everything that consumes it can take a null, androundTois the most widely shared of those consumers. Callers outside the method I changed were never checked.Consumers
Needs the usual submodule bump.
soon-market-apiis the urgent one — it is where the 500 is.event-processor-contractshould follow for consistency.Verification
soon-market-apicompiles against this source. The change cannot break an existing caller: anything passing a non-null value behaves exactly as before, and anything passing null was throwing.🤖 Generated with Claude Code