fix: Do not capture 404 responses from external APIs at Sentry#904
Conversation
|
@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR downgrages 404 responses from external APIs (Jupiter price, Jupiter verification, CoinGecko, Rugcheck) from error/panic-level logging with Sentry capture to silent
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant RouteHandler
participant ExternalAPI as External API (Jupiter/CoinGecko/Rugcheck)
participant Logger
participant Sentry
Client->>RouteHandler: GET /api/...
RouteHandler->>ExternalAPI: fetch(url, headers)
alt HTTP 404 (token/coin not found)
ExternalAPI-->>RouteHandler: 404 Not Found
RouteHandler->>Logger: Logger.debug("... not found") [no Sentry]
RouteHandler-->>Client: Error response (404 or 502)
else HTTP 429 (rate limit)
ExternalAPI-->>RouteHandler: 429 Too Many Requests
RouteHandler->>Logger: Logger.warn(..., {sentry: true})
Logger->>Sentry: capture warning
RouteHandler-->>Client: 429
else Other HTTP error
ExternalAPI-->>RouteHandler: 5xx / other
RouteHandler->>Logger: Logger.error/panic(..., {sentry: true})
Logger->>Sentry: capture error
RouteHandler-->>Client: 502
else HTTP 200 OK
ExternalAPI-->>RouteHandler: 200 + JSON body
RouteHandler-->>Client: 200 + data
end
Reviews (1): Last reviewed commit: "fix: Do not capture 404 responses from e..." | Re-trigger Greptile |
| } | ||
|
|
||
| if (!RUGCHECK_API_KEY) { | ||
| const apiKey = process.env.RUGCHECK_API_KEY; |
There was a problem hiding this comment.
I prefer the previous version, as other tokens are provided this way
There was a problem hiding this comment.
But you can't mock it in tests with the previous version (actually you can, but it makes the tests harder to read and write, and it slows them down a bit). That's not a problem for others, because they don't have any tests.
There was a problem hiding this comment.
I mean, the previous one was RUGCHECK_API_KEY = process.env.RUGCHECK_API_KEY. I agree with the fact that we have to move it inside the function. I mean that literal in CAPS is visible like a constant. apiKey is not
|
|
||
| if (!response.ok) { | ||
| if (response.status === 429) { | ||
| if (response.status === 400 || response.status === 404) { |
There was a problem hiding this comment.
Let's handle only 404 here. It is good to see 400s, as maybe we might have errors with passing mints to the endpoint
There was a problem hiding this comment.
We have a lot of spam here due to the 400 status. They return an incorrect status for the error. Perhaps it would be better to add body message parsing? This would help differentiate between a 'true' 400 error and a 404 masked as a 400 with a special body.
There was a problem hiding this comment.
Added a body check to differentiate between 400 status errors
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…rresponding tests
Description
External APIs (Jupiter, CoinGecko, Rugcheck) return 404 for tokens or coins that simply don't exist — a normal scenario, not an error. Downgrade 404s to Logger.debug so they no longer trigger Sentry alerts, matching the existing pattern in the OSEC verified-programs route.
Type of change
Testing
Related Issues
Closes HOO-363
Checklist