Debug-print HTTP body and headers on publish failure #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.