decoder: Ensure partially unknown dependent body is handled #339
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.
As demonstrated by the attached test, we can have a situation of "nested dependent modules" which was previously handled incorrectly. This is best explained on an example.
Above, we have multiple dependent body schemas for the
data
block:terraform_remote_state
- that brings usbackend
,workspace
and other attributes generally relevant for that particular data sourcebackend
(i.e. attribute which was brought in as dependent from the earlier merging).In the example above we would succeed in the first lookup, but fail in the second one - because we don't evaluate the expression in this context and cannot tell what
var.terraform_rs.backend
actually is. This is basically equivalent to any other invalid value, such asbackend = "foobar"
but the example above is a little more realistic. Now we report a more granular state reflecting the reality more accurately.This is perhaps not ideal in the sense that although we suppress irrelevant diagnostics, we also suppress some helpful ones, e.g. invalid
backend
Also we could run the validation in the top example with interpolated
var.terraform_rs.backend
, i.e. validateconfig
in the context ofbackend = "azurerm"
but interpolation is whole another problem we haven't really tackled yet.We can treat this as an opportunity for future enhancements while reducing false negatives in the meantime.
UX Before
UX After