Stop a placeholder zero replacing the Powerball jackpot with $0 - #132
Merged
Conversation
The site showed "Estimated jackpot $0 / Cash value $0" for Powerball while Mega Millions rendered correctly - the two use different sources. NY Lottery publishes the next draw entry before its jackpot is announced, with zeros in it. Every check on the path used "is not null", and zero is not null: the feed's filter accepted the entry (EstimatedJackpot is not null) ordering by draw time then PREFERRED it (it is the newest entry) RefreshGame persisted it (NextEstimatedJackpot is not null) the store's good value was overwritten with 0 formatJackpot(0) renders "$0", which is truthy, so the card shows it No lottery jackpot is zero - Powerball's floor is $20 million - so a non-positive figure means "not announced yet", never a real amount. Treated as absent in two places: - NyLotteryJackpotFeed ignores zeroed entries and prefers a draw that carries an announced figure, so a zeroed later draw no longer wins on recency - RefreshGame will not persist a non-positive estimate, so no source can poison the store this way Skipping the save leaves the previous estimate standing, which is what the card should keep showing until the real number lands. Four tests; the three that reproduce the bug were each verified to fail against the previous code, and the fourth pins that a genuine new figure still replaces the stored one. 325 tests pass. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWkVh7cyAz1gWapBH1CY8n
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.
The site shows "Estimated jackpot $0 / Cash value $0" for Powerball while Mega Millions renders correctly. The two use different sources, which is the clue.
The chain
NY Lottery publishes the next draw entry before its jackpot is announced, with zeros in it. Every check along the path used
is not null— and zero is not null:d.EstimatedJackpot is not null→ accepted the zeroed entryOrderByDescending(DrawTime)→ preferred it, being the newestRefreshGameNextEstimatedJackpot is not null→ persisted the zeroformatJackpot(0)→"$0", a truthy string, so the card renders itThe frontend is not at fault:
formatJackpot(null)returnsnulland the block is hidden. A visible$0proves the API served a real zero.Mega Millions was unaffected because it reads
megamillions.com, not the NY API.The fix
No lottery jackpot is zero — Powerball's floor is $20 million — so a non-positive figure means "not announced yet", never a real amount. Treated as absent in two places:
NyLotteryJackpotFeedignores zeroed entries, and prefers a draw carrying an announced figure — so a zeroed later draw no longer wins on recency.RefreshGamewon't persist a non-positive estimate, so no source can poison the store this way.Skipping the save leaves the previous estimate standing, which is what the card should keep showing until the real number lands. That's the graceful degradation the codebase already aims for elsewhere.
Tests
Four, and the three that reproduce the bug were each verified to fail against the previous code:
NyLottery_ZeroJackpotOnTheNextDraw_IsNotAFigure— the exact live payload shapeNyLottery_PrefersAnAnnouncedDrawOverAZeroedLaterOne— ordering no longer picks the placeholderAZeroJackpot_DoesNotOverwriteTheStoredEstimate— the good value survivesARealJackpot_StillReplacesTheStoredEstimate— the control: the guard must not freeze the value325 tests pass,
dotnet build -warnaserrorzero warnings.After merging
The card will keep showing whatever was last stored. If the store already holds
0from before this fix, the next successful refresh with a real figure overwrites it — orPOST /internal/refreshforces it immediately once NY announces the Wednesday jackpot.🤖 Generated with Claude Code