fix: return proper error if OIDC Discoverydoc fails to respond (#17242)

This commit is contained in:
jiuker 2023-05-19 17:13:33 +08:00 committed by GitHub
parent 7d433f16c4
commit e94e6adf91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ func parseDiscoveryDoc(ustr string) (DiscoveryDoc, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return d, err return d, fmt.Errorf("unexpected error returned by %s : status(%s)", ustr, resp.Status)
} }
dec := json.NewDecoder(resp.Body) dec := json.NewDecoder(resp.Body)
if err = dec.Decode(&d); err != nil { if err = dec.Decode(&d); err != nil {

View File

@ -279,7 +279,7 @@ func parseDiscoveryDoc(u *xnet.URL, transport http.RoundTripper, closeRespFn fun
} }
defer closeRespFn(resp.Body) defer closeRespFn(resp.Body)
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return d, err return d, fmt.Errorf("unexpected error returned by %s : status(%s)", u, resp.Status)
} }
dec := json.NewDecoder(resp.Body) dec := json.NewDecoder(resp.Body)
if err = dec.Decode(&d); err != nil { if err = dec.Decode(&d); err != nil {