Improve unclear provider resolver error messages (#1003)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
Christian Mesh 2023-12-12 13:10:16 -05:00 committed by GitHub
parent 25a6f51732
commit f1a57344bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -91,7 +91,7 @@ func TestProviderDevOverrides(t *testing.T) {
if got, want := stdout, `Provider development overrides are in effect`; !strings.Contains(got, want) {
t.Errorf("stdout doesn't include the warning about development overrides\nwant: %s\n%s", want, got)
}
if got, want := stderr, `Failed to query available provider packages`; !strings.Contains(got, want) {
if got, want := stderr, `Failed to resolve provider packages`; !strings.Contains(got, want) {
t.Errorf("stderr doesn't include the error about listing unavailable development provider\nwant: %s\n%s", want, got)
}
}

View File

@ -715,8 +715,8 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
default:
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Failed to query available provider packages",
fmt.Sprintf("Could not retrieve the list of available versions for provider %s: %s",
"Failed to resolve provider packages",
fmt.Sprintf("Could not resolve provider %s: %s",
provider.ForDisplay(), err,
),
))

View File

@ -2803,11 +2803,10 @@ func TestInit_testsWithProvider(t *testing.T) {
got := ui.ErrorWriter.String()
want := `
Error: Failed to query available provider packages
Error: Failed to resolve provider packages
Could not retrieve the list of available versions for provider
hashicorp/test: no available releases match the given constraints 1.0.1,
1.0.2
Could not resolve provider hashicorp/test: no available releases match the
given constraints 1.0.1, 1.0.2
`
if diff := cmp.Diff(got, want); len(diff) > 0 {

View File

@ -329,6 +329,8 @@ NeedProvider:
err = fmt.Errorf("the previously-selected version %s is no longer available", lock.Version())
} else {
err = fmt.Errorf("no available releases match the given constraints %s", getproviders.VersionConstraintsString(reqs[provider]))
log.Printf("[DEBUG] %s", err.Error())
log.Printf("[DEBUG] Available releases: %s", available)
}
errs[provider] = err
if cb := evts.QueryPackagesFailure; cb != nil {