-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
terraform: improve provider config related error messages #27261
Conversation
config If there is no provider configuration present in the config at all, errors related to missing required arguments lack source information or even a reference to the provider in question. This PR adds more specific error messages in three of these situations: - ValidateProvider - ConfigureProvider: provider.PrepareProviderConfig - ConfigureProvider: ctx.ConfigureProvider To test the last case I added a ConfigureProviderFn to the MockContext.
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution to a confusing bug!
Provider %q requires explicit configuration. Add a provider block to the root | ||
module and configure the provider's required arguments as described in the | ||
provider documentation. | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already tried changing the newlines - including one long single line with no newlines - and it didn't improve the output, do you know how else I might improve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. Making the last paragraph a single line seemed to work for me:
diff --git a/terraform/node_provider.go b/terraform/node_provider.go
index 57245fafb..001408bf2 100644
--- a/terraform/node_provider.go
+++ b/terraform/node_provider.go
@@ -185,7 +185,4 @@ func (n *NodeApplyableProvider) ConfigureProvider(ctx EvalContext, provider prov
const providerConfigErr = `%s
-Provider %q requires explicit configuration. Add a provider block to the root
-module and configure the provider's required arguments as described in the
-provider documentation.
-`
+Provider %q requires explicit configuration. Add a provider block to the root module and configure the provider's required arguments as described in the provider documentation.`
Result:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize, my error - I tried what I thought I already tried before and it now looks better. Sorry!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
If there is no "provider" block present in the configuration at all,
errors related to missing required arguments lack source information or
even a reference to the provider in question. This PR adds more specific
error messages in three of these situations:
To test the last case I added a ConfigureProviderFn to the MockContext.
Closes #20121, #26707, #23087