Skip to content

Commit

Permalink
internal/getproviders: Add URL to error message for clarity (#30810)
Browse files Browse the repository at this point in the history
* internal/getproviders: Add URL to error message for clarity

Occasionally `terraform init` on some providers may return the following error message:

Error while installing citrix/citrixadc v1.13.0: could not query provider
registry for registry.terraform.io/citrix/citrixadc: failed to retrieve
authentication checksums for provider: 403 Forbidden

The 403 is most often returned from GitHub (rather than Registry API)
and this change makes it more obvious.

* Use Host instead of full URL
  • Loading branch information
radeksimko committed Apr 14, 2022
1 parent 696bd4c commit 746af01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/getproviders/registry_client.go
Expand Up @@ -437,7 +437,7 @@ func (c *registryClient) getFile(url *url.URL) ([]byte, error) {
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", resp.Status)
return nil, fmt.Errorf("%s returned from %s", resp.Status, resp.Request.Host)
}

data, err := ioutil.ReadAll(resp.Body)
Expand Down Expand Up @@ -478,7 +478,7 @@ func maxRetryErrorHandler(resp *http.Response, err error, numTries int) (*http.R
// both response and error.
var errMsg string
if resp != nil {
errMsg = fmt.Sprintf(": %s returned from %s", resp.Status, resp.Request.URL)
errMsg = fmt.Sprintf(": %s returned from %s", resp.Status, resp.Request.Host)
} else if err != nil {
errMsg = fmt.Sprintf(": %s", err)
}
Expand Down

0 comments on commit 746af01

Please sign in to comment.