Skip to content

fix(api): validate HTTP status code in Solana RPC GetTotalSupply - #4279

Open
Tyagiquamar wants to merge 2 commits into
malbeclabs:mainfrom
Tyagiquamar:fix/api-solana-rpc-http-status-check
Open

fix(api): validate HTTP status code in Solana RPC GetTotalSupply#4279
Tyagiquamar wants to merge 2 commits into
malbeclabs:mainfrom
Tyagiquamar:fix/api-solana-rpc-http-status-check

Conversation

@Tyagiquamar

Copy link
Copy Markdown

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:

  1. Validates that
    esp.StatusCode == http.StatusOK\ before attempting JSON deserialization and returns a clear status error otherwise.
  2. Adds unit test coverage (\TestSolanaClient_GetTotalSupply_HTTPError) in \�pi/internal/server_test.go.

@Tyagiquamar
Tyagiquamar requested a review from a team September 4, 2026 18:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread api/internal/server_test.go Outdated

_, err := client.GetTotalSupply(context.Background())
require.Error(t, err)
assert.Contains(t, err.Error(), "unexpected status code: 429")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Triggered by project rule: Comment shape

Reviewed by Cursor Bugbot for commit 62cb868. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant