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

fix: httpcode error #1257

Merged
merged 9 commits into from
Dec 4, 2023
Merged

fix: httpcode error #1257

merged 9 commits into from
Dec 4, 2023

Conversation

constwz
Copy link
Contributor

@constwz constwz commented Nov 30, 2023

Description
Addressing the issue of inaccurate error codes in the gateway interface.

Rationale
The error message is lost during the RPC call process, and we need to reparse it.

Example
“the specified bucket does not exist”
The error should return a 404, but it is actually returning a 500.

Changes
Notable changes:

Modified the string method of gfspError to make it easier to parse.
Added parsing logic to the gateway.
Potential Impacts
print log
http code

@constwz constwz force-pushed the fix-httpcode branch 2 times, most recently from d499a6e to d9dc0f0 Compare November 30, 2023 05:41
@constwz constwz force-pushed the fix-httpcode branch 2 times, most recently from 19362cc to 954c4da Compare November 30, 2023 05:48
errInfo := err.Error()[i+6:]
var gfspErr GfSpError
unmarshalErr := json.Unmarshal([]byte(errInfo), &gfspErr)
if unmarshalErr == nil && gfspErr.HttpStatusCode != 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does the 0 here mean? 200 means http is successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

0 indicates that err information is successfully resolved

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use gfspErr.InnerCode != 0? I think gfspErr.HttpStatusCode should be 200 by default.

@will-2012
Copy link
Collaborator

Refine the PR Title, fix:httpcode error --> fix: httpcode error to keep a consistent style, and maybe the title can be clearer.

@constwz constwz changed the title fix:httpcode error fix: httpcode error Nov 30, 2023
@constwz
Copy link
Contributor Author

constwz commented Nov 30, 2023

Refine the PR Title, fix:httpcode error --> fix: httpcode error to keep a consistent style, and maybe the title can be clearer.

done

Copy link
Collaborator

@sysvm sysvm left a comment

Choose a reason for hiding this comment

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

LGTM

@constwz constwz merged commit c917422 into develop Dec 4, 2023
11 checks passed
@constwz constwz deleted the fix-httpcode branch December 4, 2023 16:11
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.

5 participants