-
Notifications
You must be signed in to change notification settings - Fork 942
Fix: Change account disabled code #4899
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1920,12 +1920,12 @@ func writeError(errs []error, w http.ResponseWriter, labels *metrics.Labels) boo | |||||||||||||
| httpStatus := http.StatusBadRequest | ||||||||||||||
| metricsStatus := metrics.RequestStatusBadInput | ||||||||||||||
| for _, err := range errs { | ||||||||||||||
| erVal := errortypes.ReadCode(err) | ||||||||||||||
| if erVal == errortypes.BlockedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode { | ||||||||||||||
| httpStatus = http.StatusServiceUnavailable | ||||||||||||||
| switch errortypes.ReadCode(err) { | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Go, I measured it with the same probe on the base commit
To be fair: this is latent, not a live regression — Either drop the redundant loop:
for _, err := range errs {
switch errortypes.ReadCode(err) {
case errortypes.BlockedAppErrorCode, errortypes.AccountDisabledErrorCode:
httpStatus = http.StatusForbidden
metricsStatus = metrics.RequestStatusBlockedApp
break loop
case errortypes.MalformedAcctErrorCode:
httpStatus = http.StatusInternalServerError
metricsStatus = metrics.RequestStatusAccountConfigErr
break loop
}
} |
||||||||||||||
| case errortypes.BlockedAppErrorCode, errortypes.AccountDisabledErrorCode: | ||||||||||||||
| httpStatus = http.StatusForbidden | ||||||||||||||
| metricsStatus = metrics.RequestStatusBlockedApp | ||||||||||||||
| break | ||||||||||||||
| } else if erVal == errortypes.MalformedAcctErrorCode { | ||||||||||||||
| case errortypes.MalformedAcctErrorCode: | ||||||||||||||
| httpStatus = http.StatusInternalServerError | ||||||||||||||
| metricsStatus = metrics.RequestStatusAccountConfigErr | ||||||||||||||
| break | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -428,16 +428,16 @@ func handleError(labels *metrics.Labels, w http.ResponseWriter, errL []error, vo | |
| var errors string | ||
| var status int = http.StatusInternalServerError | ||
| for _, er := range errL { | ||
| erVal := errortypes.ReadCode(er) | ||
| if erVal == errortypes.BlockedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode { | ||
| status = http.StatusServiceUnavailable | ||
| switch errortypes.ReadCode(er) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as in Worth pinning whichever semantics you settle on with a test: |
||
| case errortypes.BlockedAppErrorCode, errortypes.AccountDisabledErrorCode: | ||
| status = http.StatusForbidden | ||
| labels.RequestStatus = metrics.RequestStatusBlockedApp | ||
| break | ||
| } else if erVal == errortypes.AcctRequiredErrorCode { | ||
| case errortypes.AcctRequiredErrorCode: | ||
| status = http.StatusBadRequest | ||
| labels.RequestStatus = metrics.RequestStatusBadInput | ||
| break | ||
| } else if erVal == errortypes.MalformedAcctErrorCode { | ||
| case errortypes.MalformedAcctErrorCode: | ||
| status = http.StatusInternalServerError | ||
| labels.RequestStatus = metrics.RequestStatusAccountConfigErr | ||
| break | ||
|
|
||
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.
Minor consistency point: this site was left as an
if / else ifwhileauction.goandvideo_auction.gowere converted to aswitchin the same diff. That is not wrong — in fact this is the only one of the three that still short-circuits the loop correctly — but it does mean the three copies of this logic now differ in both style and behaviour.Either convert all three or none; if you keep the
switchelsewhere, this one is the reference for what the loop is supposed to do.