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

refactor: make http api returns non-200 status code #3473

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

crwen
Copy link
Contributor

@crwen crwen commented Mar 10, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#2888

What's changed and what's your intention?

to make HTTP API returns status code, I changed the returning value of ErrorResponse::into_response and map code to StatusCode. Here is the returning mapping:

Success, Cancelled ==> OK(200);

Unsupported, InvalidArguments, InvalidSyntax, RequestOutdated, 
RegionAlreadyExists, TableColumnExists, TableAlreadyExists, 
DatabaseNotFound, TableNotFound, TableColumnNotFound ==> `BAD_REQUEST`(400);

PermissionDenied, AuthHeaderNotFound, InvalidAuthHeader, 
UserNotFound, UnsupportedPasswordType, UserPasswordMismatch, 
RegionReadonly ==> `UNAUTHORIZED`(401)

AccessDenied ==> `FORBIDDEN`(403)

Internal, Unexpected, Unknown, StorageUnavailable,
RegionNotReady, RegionBusy, RateLimited, RuntimeResourcesExhausted, 
PlanQuery, EngineExecuteQuery ==> `INTERNAL_SERVER_ERROR`(500)

I also changed some test code to match these status code.

some code may need to be changed on front-end(like dashboard) to handle these error code

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Mar 10, 2024
Copy link
Collaborator

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

@tisonkun tisonkun added this to the v0.8 milestone Mar 11, 2024
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.07%. Comparing base (21ff362) to head (99a72e5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3473      +/-   ##
==========================================
- Coverage   85.46%   85.07%   -0.39%     
==========================================
  Files         896      896              
  Lines      147546   147546              
==========================================
- Hits       126097   125532     -565     
- Misses      21449    22014     +565     

@shuiyisong shuiyisong self-requested a review March 11, 2024 03:25
@shuiyisong shuiyisong added this pull request to the merge queue Mar 11, 2024
Merged via the queue into GreptimeTeam:main with commit aa125a5 Mar 11, 2024
17 checks passed
tisonkun added a commit that referenced this pull request Apr 9, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants