fix(api): validate HTTP status code in Solana RPC GetTotalSupply - #4279
fix(api): validate HTTP status code in Solana RPC GetTotalSupply#4279Tyagiquamar wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 62cb868. Configure here.
|
|
||
| _, err := client.GetTotalSupply(context.Background()) | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "unexpected status code: 429") |
There was a problem hiding this comment.
Test matches error substring
Low Severity
Issue
The new test matches a substring of the error text. This violates the test rule that forbids .contains() and .is_err() checks.
Context
The mock RPC returns HTTP 429. The test calls GetTotalSupply and then uses require.Error and assert.Contains on the text unexpected status code: 429.
Proposed Fix
Assert the exact error unexpected status code: 429.
Triggered by project rule: Comment shape
Reviewed by Cursor Bugbot for commit 62cb868. Configure here.


In \�pi/internal/rpc.go, \GetTotalSupply\ previously passed non-200 HTTP responses (e.g., HTTP 429 rate limit or 503 gateway error) directly to \json.NewDecoder(resp.Body).Decode(&rpcResp). This resulted in obscure JSON decoding error messages ('EOF' or 'invalid character') rather than identifying the upstream RPC HTTP status failure.
This fix:
esp.StatusCode == http.StatusOK\ before attempting JSON deserialization and returns a clear status error otherwise.