-
Notifications
You must be signed in to change notification settings - Fork 182
fix: RPC response code for unsupported methods #6178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis pull request fixes the error code returned for unsupported RPC methods by replacing hard-coded values with the standard JSON-RPC error constants from jsonrpsee. The fix is verified by a new integration test and documented in the changelog. Changes
Sequence DiagramsequenceDiagram
participant Client
participant RPC Server
participant Segregation Layer
Client->>RPC Server: POST /rpc/v1<br/>(unsupported method)
RPC Server->>Segregation Layer: check(method)
alt Method Not Found
Segregation Layer->>Segregation Layer: Use METHOD_NOT_FOUND_CODE (-32601)<br/>and METHOD_NOT_FOUND_MSG
Segregation Layer-->>RPC Server: ErrorObject with -32601
end
RPC Server-->>Client: HTTP 200<br/>{"error": {"code": -32601, ...}}
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes The changes follow a straightforward pattern: importing standard error constants and applying them consistently across one implementation file, one test file, and documentation. The logic density is low with no complex control flow modifications. Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
92139d6 to
22642ea
Compare
22642ea to
5f0d38f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
scripts/tests/calibnet_other_check.sh (1)
87-94: Good test coverage for the RPC error code fix.The test correctly verifies that unsupported RPC methods return the JSON-RPC standard error code -32601. This will prevent regression of the issue.
Optional enhancement: You could also verify the error message to ensure complete correctness:
error_code=$(echo "$unsupported_response" | jq -r '.error.code') +error_message=$(echo "$unsupported_response" | jq -r '.error.message') if [ "$error_code" != "-32601" ]; then echo "Unexpected error code for unsupported method: $error_code" exit 1 fi +if [ "$error_message" != "Method not found" ]; then + echo "Unexpected error message for unsupported method: $error_message" + exit 1 +fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CHANGELOG.md(1 hunks)scripts/tests/calibnet_other_check.sh(1 hunks)src/rpc/segregation_layer.rs(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Build MacOS
- GitHub Check: cargo-publish-dry-run
- GitHub Check: Build Ubuntu
- GitHub Check: All lint checks
- GitHub Check: Check
- GitHub Check: Build forest binaries on Linux AMD64
- GitHub Check: tests
- GitHub Check: tests-release
🔇 Additional comments (3)
CHANGELOG.md (1)
48-49: LGTM! Changelog entry is clear and properly formatted.The entry accurately describes the fix for the incorrect error code issue. The formatting is consistent with other entries in the changelog.
src/rpc/segregation_layer.rs (2)
12-12: LGTM! Correct import of JSON-RPC standard error constants.Using the library-provided constants ensures consistency with the JSON-RPC specification and makes the code more maintainable.
72-73: Excellent fix! Correctly uses JSON-RPC error codes instead of HTTP status codes.This change properly aligns the error response with the JSON-RPC 2.0 specification. The error code -32601 ("Method not found") is the standard code for unsupported methods, replacing the previously incorrect HTTP 404 status code. Using
METHOD_NOT_FOUND_CODEandMETHOD_NOT_FOUND_MSGconstants from jsonrpsee ensures consistency and maintainability.
Summary of changes
Changes introduced in this pull request:
404but it's an HTTP code. Fixed it to-32601.Reference issue to close (if applicable)
Other information and links
Change checklist
Summary by CodeRabbit
Bug Fixes
Tests