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: 避免status_code>=400并且resp为空时err为nil #7264
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
pkg/util/httputils/httputils.go
Outdated
@@ -151,13 +151,10 @@ func (ce *JSONClientError) ParseErrorFromJsonResponse(statusCode int, body jsonu | |||
if err != nil { | |||
return errors.Wrapf(err, "body.Unmarshal(%s)", body.String()) |
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.
func (ce *JSONClientError) ParseErrorFromJsonResponse(statusCode int, body jsonutils.JSONObject) error {
body.Unmarshal(ce)
if ce.Code == 0 {
ce.Code = statuacode
}
if len(ce.Class) == 0 {
ce.Class = http.StatusText(statuscode)
}
if len(ce.Details) == 0 {
ce.Details = body.String()
}
return ce
}
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.
无论如何都要返回一个JSONClientError,并且不应该丢失信息
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.
已更新
90d9662
to
f4da2af
Compare
f4da2af
to
e797d3d
Compare
e797d3d
to
4ddac47
Compare
/lgtm |
1 similar comment
/lgtm |
/lgtm |
/approve |
2 similar comments
/approve |
/approve |
/lgtm |
/approve |
1 similar comment
/approve |
/approve |
/lgtm |
/approve |
2 similar comments
/approve |
/approve |
这个 PR 实现什么功能/修复什么问题:
fix: 避免status_code>=400并且resp为空时err为nil
是否需要 backport 到之前的 release 分支:
/area region
/cc @zexi