Skip to content
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

feat: improved RPC's response error handling with HTTP status codes #11806

Merged
merged 6 commits into from
Jul 20, 2024

Conversation

frolvanya
Copy link
Contributor

This PR updates the RPC handler to return appropriate HTTP errors for specific RPC issues, improving error visibility for operators

closes #11792

@frolvanya frolvanya requested a review from a team as a code owner July 17, 2024 17:47
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
@frolvanya
Copy link
Contributor Author

On the one hand, this makes sense. However, If we will send a structure other than Result, then we will have to rewrite jsonrpc tests. Is it worth it?
image

Also, we need to make Version struct pub, it's not necessarily a bad idea, but it's definetely a small overhead
image

And process function in the very end will have these ugly raw response builders:
image

@frolvanya
Copy link
Contributor Author

@shreyan-gupta Sorry, it took a bit longer than expected, but I removed Result from process function

Co-authored-by: Shreyan Gupta <shreyan.gupta96@gmail.com>
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 51.51515% with 16 lines in your changes missing coverage. Please review.

Project coverage is 71.75%. Comparing base (d7e1232) to head (f1b8323).
Report is 11 commits behind head on master.

Files Patch % Lines
chain/jsonrpc/src/lib.rs 51.51% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11806      +/-   ##
==========================================
+ Coverage   71.74%   71.75%   +0.01%     
==========================================
  Files         796      796              
  Lines      163004   163183     +179     
  Branches   163004   163183     +179     
==========================================
+ Hits       116940   117095     +155     
- Misses      41003    41038      +35     
+ Partials     5061     5050      -11     
Flag Coverage Δ
backward-compatibility 0.23% <0.00%> (-0.01%) ⬇️
db-migration 0.23% <0.00%> (-0.01%) ⬇️
genesis-check 1.35% <0.00%> (-0.01%) ⬇️
integration-tests 37.83% <33.33%> (+<0.01%) ⬆️
linux 71.37% <51.51%> (+0.12%) ⬆️
linux-nightly 71.35% <51.51%> (+0.01%) ⬆️
macos 54.61% <51.51%> (+1.66%) ⬆️
pytests 1.62% <0.00%> (+0.03%) ⬆️
sanity-checks 1.42% <0.00%> (+0.03%) ⬆️
unittests 66.21% <51.51%> (+0.02%) ⬆️
upgradability 0.28% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@frolvanya
Copy link
Contributor Author

@race-of-sloths please, include my PR in the Race

@race-of-sloths
Copy link

race-of-sloths commented Jul 18, 2024

@frolvanya Thank you for your contribution! Your pull request is now a part of the Race of Sloths!

Shows profile picture for the author of the PR

Current status: executed

@frolvanya check out your results on the Race of Sloths Leaderboard! and in the profile

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

chain/jsonrpc/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@khorolets khorolets left a comment

Choose a reason for hiding this comment

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

LGTM! That has to be done long time ago, thank you!

@khorolets khorolets added this pull request to the merge queue Jul 20, 2024
Merged via the queue into near:master with commit db0644f Jul 20, 2024
28 of 30 checks passed
@race-of-sloths
Copy link

🔄 The PR has been merged.

Important

This pull request is a part of the Race of Sloths and has not been scored yet. Scoring will close in 24 hours! 🕰️

@race-of-sloths
Copy link

✅ PR is finalized!

Your contribution is much appreciated with a final score of 0!
You have received 0 Sloth points for this contribution

github-merge-queue bot pushed a commit that referenced this pull request Jul 25, 2024
This PR fixes a small issue that was introduced in #11806

Internal error - 500 status code
Handler error - 408 if it's a `TIMEOUT_ERROR`, otherwise 200
Request validation error - 400 status code

closes #11792
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.

Consider returning http errors for certain rpc errors
5 participants