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

Print error for failed HTTP auth request. #1249

Merged
merged 3 commits into from
Jan 5, 2016
Merged

Print error for failed HTTP auth request. #1249

merged 3 commits into from
Jan 5, 2016

Conversation

k4leung4
Copy link
Contributor

@k4leung4 k4leung4 commented Dec 8, 2015

In the case of a failed HTTP auth token request, in addition to the current message that is returned, also return the error message in the response. This is to provide the user with a more descriptive message about what went wrong.

Signed-off-by: Kenny Leung kleung@google.com

Signed-off-by: Kenny Leung <kleung@google.com>
@mattmoor
Copy link
Contributor

@stevvooe @dmcgowan @aaronlehmann FYI

@stevvooe
Copy link
Collaborator

Code LGTM.

@k4leung4 Any tests for this?

@@ -240,7 +240,8 @@ func (th *tokenHandler) fetchToken(params map[string]string) (token *tokenRespon
defer resp.Body.Close()

if !client.SuccessStatus(resp.StatusCode) {
return nil, fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode))
err := client.HandleErrorResponse(resp)
return nil, fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s: %q", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode), err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems odd to throw away a nicely typed error for a formatted string here. Perhaps any additional messaging about failure to fetch a token should be left to the caller.

@dmp42
Copy link
Contributor

dmp42 commented Dec 22, 2015

@k4leung4 This needs a rebase, tests, and addressing @dmcgowan comments :)

@mattmoor
Copy link
Contributor

FYI, he's on vacation this week. I will ping him Monday. :)

@dmp42
Copy link
Contributor

dmp42 commented Dec 22, 2015

Thanks @mattmoor
It's just a friendly bump either way - I don't expect anything to happen before next year :p

Signed-off-by: Kenny Leung <kleung@google.com>
…ution into print-error-msg

Changed to use typed error instead of formatted string.
Added tests for new public method.

Signed-off-by: Kenny Leung <kleung@google.com>
@k4leung4
Copy link
Contributor Author

Changed to make use of typed error instead of formatted string.
Added tests.

please take another look.

@codecov-io
Copy link

Current coverage is 57.60%

Merging #1249 into master will increase coverage by +0.07% as of 7ff5042

@@            master   #1249   diff @@
======================================
  Files          116     116       
  Stmts        10468   10469     +1
  Branches       719     719       
  Methods          0       0       
======================================
+ Hit           6023    6031     +8
  Partial        719     719       
+ Missed        3726    3719     -7

Review entire Coverage Diff as of 7ff5042


Uncovered Suggestions

  1. +0.31% via ...ge/driver/gcs/gcs.go#185...216
  2. +0.31% via ...ge/driver/gcs/gcs.go#104...135
  3. +0.23% via ...ge/driver/gcs/gcs.go#469...492
  4. See 7 more...

Powered by Codecov. Updated on successful CI builds.

@stevvooe
Copy link
Collaborator

LGTM

@mattmoor
Copy link
Contributor

mattmoor commented Jan 5, 2016

Anything left needed to merge this? I ask in part because of the upcoming code freeze.

@dmcgowan
Copy link
Collaborator

dmcgowan commented Jan 5, 2016

LGTM

@dmcgowan
Copy link
Collaborator

dmcgowan commented Jan 5, 2016

CI is back, lets turn this green then merge 😉

stevvooe added a commit that referenced this pull request Jan 5, 2016
Print error for failed HTTP auth request.
@stevvooe stevvooe merged commit 74d719d into distribution:master Jan 5, 2016
aaronlehmann added a commit to aaronlehmann/distribution that referenced this pull request Jan 20, 2016
distribution#1249 changed token fetching
to parse HTTP error response bodies as serialized errcodes. However,
Docker Hub's authentication endpoint does not return error bodies in
this format. To work around this, convert its format into
ErrCodeUnauthorized or ErrCodeUnknown.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
dalsh pushed a commit to dalsh/distribution that referenced this pull request Jan 13, 2017
distribution#1249 changed token fetching
to parse HTTP error response bodies as serialized errcodes. However,
Docker Hub's authentication endpoint does not return error bodies in
this format. To work around this, convert its format into
ErrCodeUnauthorized or ErrCodeUnknown.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Apr 22, 2021
Print error for failed HTTP auth request.
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Apr 22, 2021
distribution#1249 changed token fetching
to parse HTTP error response bodies as serialized errcodes. However,
Docker Hub's authentication endpoint does not return error bodies in
this format. To work around this, convert its format into
ErrCodeUnauthorized or ErrCodeUnknown.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Jan 19, 2022
Print error for failed HTTP auth request.
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Jan 19, 2022
distribution#1249 changed token fetching
to parse HTTP error response bodies as serialized errcodes. However,
Docker Hub's authentication endpoint does not return error bodies in
this format. To work around this, convert its format into
ErrCodeUnauthorized or ErrCodeUnknown.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
dylanrhysscott pushed a commit to digitalocean/docker-distribution that referenced this pull request Jan 5, 2023
distribution#1249 changed token fetching
to parse HTTP error response bodies as serialized errcodes. However,
Docker Hub's authentication endpoint does not return error bodies in
this format. To work around this, convert its format into
ErrCodeUnauthorized or ErrCodeUnknown.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
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.

None yet

7 participants