Ignore scope suggestions for http 422 (#4809)
HTTP 422 messages are for validation errors, but OAUTH permissions suggestions get printed anyways. Most times, the user probably has the right permissions. This fix adds the check to avoid printing a confusing message. Co-authored-by: Mislav Marohnić <mislav@github.com>
This commit is contained in:
parent
6906dea671
commit
8f9548fd37
2 changed files with 6 additions and 1 deletions
|
|
@ -206,7 +206,7 @@ func (err HTTPError) ScopesSuggestion() string {
|
|||
// ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth
|
||||
// scopes in case a server response indicates that there are missing scopes.
|
||||
func ScopesSuggestion(resp *http.Response) string {
|
||||
if resp.StatusCode < 400 || resp.StatusCode > 499 {
|
||||
if resp.StatusCode < 400 || resp.StatusCode > 499 || resp.StatusCode == 422 {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,6 +208,11 @@ func TestHTTPError_ScopesSuggestion(t *testing.T) {
|
|||
resp: makeResponse(404, "https://api.github.com/gists", "", "gist, delete_repo"),
|
||||
want: ``,
|
||||
},
|
||||
{
|
||||
name: "http code is 422",
|
||||
resp: makeResponse(422, "https://api.github.com/gists", "", "gist"),
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue