fix(api): floor NFT price rolling average to keep wei strings BigInt-safe#2023
Merged
Conversation
…safe Postgres AVG() over NUMERIC always emits decimal text (e.g. "200.5000000000000000"), and NFTPriceService converts the repository's price strings straight through BigInt(), which rejects decimals. Every /token/historical-data request on Nouns/Lil Nouns 500'd, and five consecutive failures opened the gateway circuit breaker, taking the whole DAO offline with "DAO service temporarily unavailable". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Collaborator
🎨 UI Review
This PR only touches Generated by Claude Code |
pikonha
approved these changes
Jul 6, 2026
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.
Summary
Hotfix for the production outage where every Nouns request through Gateful returned
{"error":"DAO service temporarily unavailable"}. Root cause:GET /token/historical-dataon NFT-priced DAOs (NOUNS, LIL_NOUNS) crashed withSyntaxError: Cannot convert 0.00000000000000000000 to a BigInton every call, and five consecutive 500s open the per-DAO gateway circuit breaker, taking the whole DAO offline for 5–40 min.Context
main(no ticket — found live-debugging prod; Railway logs confirmed the crash innouns-apiproduction)hotfix/nouns-nft-price-bigintWhat changed
NFTPriceRepository.getHistoricalNFTPricenow wraps the rolling-average window inFLOOR(...)beforeCAST(... AS TEXT). PostgresAVG()overNUMERICalways emits decimal text (e.g."200.5000000000000000"), whichBigInt()rejects inNFTPriceService— so the endpoint failed on any data. Flooring keeps the contract (integer wei string); precision loss is <1 wei.BigInt-parseable and floored ("200").Self-review summary
getTokenPricepath, huge wei values — no scientific notation)sql<string>wei contract for all consumers);FLOOR(numeric)is standard Postgres and PGlite exercises identical semanticsBigInt(price)inNFTPriceService— a future repo regression would re-trigger the circuit-breaker failure modetimestampissql<number>but cast to TEXT at runtime (string typed as number) — follow-up candidate/fluid/token/historical-data500s with a CoinGecko 404 (coin id), same breaker-opening effectChangeset
@anticapture/api: patch — endpoint bugfix, response schema unchanged (no gateful cascade needed)🤖 Generated with Claude Code