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

Debug-print HTTP body and headers on publish failure #38

Conversation

3rwww1
Copy link

@3rwww1 3rwww1 commented May 8, 2020

Be more verbose on PUT operation failure

TL;DR: Print HTTP (truncated) response body and headers when a PUT operation fails on upload to better explain why upload failed.

Long story:

Publish failure might be caused by unsufficient privileges, and 401 or 403 HTTP status code is returned. Such well-formed, standard-compliant response codes are enough for a developper to figure out credentials are either bad or missing. At the same time, repository services might enforce immutability (and return a 409 when artifact version is already published) and/or strict versioning rules (e.g returning a 400 when artifact is not semver compliant)

However, some artifact hosting services - namely Azure Artifacts - have a slightly more obfuscated AND anally-retentive behavior: those will issue a 203: Non-authoritative answer both when the credentials are bad, or something else entirely is happening, for instance when the supplied version number doesn't match with an undocumented scheme/regex...

In that case, the HTTP status code simply isn't sufficient. On a 203, a Warning header may be provided, or in any case, a full explanation may be given in the request body.

This code print headers at DEBUG logging level and truncated reponse body in the event of a publish failure on an unknow code to enhance developper experience.

3rwww1 added 2 commits May 2, 2020 15:02
TL;DR: Print HTTP body and headers when a PUT operation fails on upload
to better explain why upload failed.

Long story:

Publish failure might be caused by unsufficient privileges, and 401 or
403 HTTP status code is returned. Such well-formed, standard-compliant
response codes are enough for a developper to figure out credentials
are either bad or missing.

However, some artifact hosting services - namely Azure Artifacts - have
a slightly more obfuscated AND anally-retentive behavior: those will
issue a `203: Non-authoritative answer` both when the credentials are
bad, or something else entirely is happening, for instance when the
supplied version number doesn't match with an undocumented
scheme/regex...

In that case, the HTTP status code simply isn't sufficient. On a 203, a
`Warning` header may be provided, or in any case, a full explanation may
be given in the request body.

This code print headers at DEBUG level in the event of a publish failure
to enhance developper experience.
@3rwww1 3rwww1 changed the title Enhancement/print http body headers on publish failure Debug-print HTTP body and headers on publish failure May 8, 2020
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Thanks @3rwww1!

@SethTisue
Copy link
Member

nice

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.

3 participants