terraform/internal/configs
Martin Atkins 1879a39d2d configs: Refined error messages for mismatched provider passing
This set of diagnostic messages is under a number of unusual constraints
that make them tough to get right:
 - They are discussing a couple finicky concepts which authors are
   likely to be encountering for the first time in these error messages:
   the idea of "local names" for providers, the relationship between those
   and provider source addresses, and additional ("aliased") provider
   configurations.
 - They are reporting concerns that span across a module call boundary,
   and so need to take care to be clear about whether they are talking
   about a problem in the caller or a problem in the callee.
 - Some of them are effectively deprecation warnings for features that
   might be in use by a third-party module that the user doesn't control,
   in which case they have no recourse to address them aside from opening
   a feature request with the upstream module maintainer.
 - Terraform has, for backward-compatibility reasons, a lot of implied
   default behaviors regarding providers and provider configurations,
   and these errors can arise in situations where Terraform's assumptions
   don't match the author's intent, and so we need to be careful to
   explain what Terraform assumed in order to make the messages
   understandable.

After seeing some confusion with these messages in the community, and
being somewhat confused by some of them myself, I decided to try to edit
them a bit for consistency of terminology (both between the messages and
with terminology in our docs), being explicit about caller vs. callee
by naming them in the messages, and making explicit what would otherwise
be implicit with regard to the correspondences between provider source
addresses and local names.

My assumed audience for all of these messages is the author of the caller
module, because it's the caller who is responsible for creating the
relationship between caller and callee. As much as possible I tried to
make the messages include specific actions for that author to take to
quiet the warning or fix the error, but some of the warnings are only
fixable by the callee's maintainer and so those messages are, in effect,
a suggestion to send a request to the author to stop using a deprecated
feature.

I think these new messages are also not ideal by any means, because it's
just tough to pack so much information into concise messages while being
clear and consistent, but I hope at least this will give users seeing
these messages enough context to infer what's going on, possibly with the
help of our documentation.

I intentionally didn't change which cases Terraform will return warnings
or errors -- only the message texts -- although I did highlight in a
comment in one of the tests that what it is a asserting seems a bit
suspicious to me. I don't intend to address that here; instead, I intend
that note to be something to refer to if we later see a bug report that
calls that behavior into question.

This does actually silence some _unrelated_ warnings and errors in cases
where a provider block has an invalid provider local name as its label,
because our other functions for dealing with provider addresses are
written to panic if given invalid addresses under the assumption that
earlier code will have guarded against that. Doing this allowed for the
provider configuration validation logic to safely include more information
about the configuration as helpful context, without risking tripping over
known-invalid configuration and panicking in the process.
2022-03-10 10:05:56 -08:00
..
configload
configschema configs: Add sensitive marks for nested attributes 2021-11-25 11:55:17 -05:00
hcl2shim Move configs/ to internal/configs/ 2021-05-17 14:09:07 -07:00
testdata configs: Refined error messages for mismatched provider passing 2022-03-10 10:05:56 -08:00
backend.go
checks.go core: Check rule error message expressions 2022-03-04 15:35:39 -05:00
cloud.go
compat_shim.go
config.go
config_build.go configs: Refined error messages for mismatched provider passing 2022-03-10 10:05:56 -08:00
config_build_test.go configs: Refined error messages for mismatched provider passing 2022-03-10 10:05:56 -08:00
config_test.go
depends_on.go
doc.go
escaping_blocks_test.go
experiments.go configs: Decode preconditions and postconditions 2022-01-28 11:00:29 -05:00
experiments_test.go
module.go
module_call.go addrs: Expose the registry address parser's error messages 2021-11-30 15:46:16 -08:00
module_call_test.go
module_merge.go IgnoreAllChanges should override during merge 2021-11-01 19:08:30 +00:00
module_merge_body.go
module_merge_test.go add failing test for IgnoreAllChanges override 2021-11-01 19:00:54 +00:00
module_test.go
moved.go configs: For Moved blocks, use addrs.MoveEndpoint instead of addrs.Target 2021-07-01 08:28:02 -07:00
moved_test.go normalise test names 2021-11-14 21:51:53 +00:00
named_values.go core: Check rule error message expressions 2022-03-04 15:35:39 -05:00
parser.go
parser_config.go configs: Decode preconditions and postconditions 2022-01-28 11:00:29 -05:00
parser_config_dir.go
parser_config_dir_test.go
parser_config_test.go configs: Decode preconditions and postconditions 2022-01-28 11:00:29 -05:00
parser_test.go
parser_values.go
parser_values_test.go
provider.go configs: Refined error messages for mismatched provider passing 2022-03-10 10:05:56 -08:00
provider_meta.go
provider_requirements.go
provider_requirements_test.go
provider_test.go
provider_validation.go configs: Refined error messages for mismatched provider passing 2022-03-10 10:05:56 -08:00
provisioner.go
provisioneronfailure_string.go
provisionerwhen_string.go
resource.go configs: Validate pre/postcondition self-refs 2022-02-03 09:37:22 -05:00
synth_body.go
synth_body_test.go
util.go
variable_type_hint.go
variabletypehint_string.go
version_constraint.go