-
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
Create a dedicated schema Validation method #22484
Conversation
f14c1e3
to
8247472
Compare
51d757f
to
8fca378
Compare
8fca378
to
de524fb
Compare
Due to both the nature of dynamic blocks, and the need for resources to sometimes communicate incomplete values, we cannot validate MinItems and MaxItems during decoding or CoerceValue. Since we're reducing the early automatic validation, add a Block.Validate method to precisely validate values, once they are fully known.
If a NestingGroup block has any RequiredAttributes, automatically instantiating that would create a block missing those required attributes. This means that the block itself is essentially required, which we can enforce early in InternalValidate.
Calling this during EvalDiff allows us to validate the final configuration, immediately after all values have been evaluated. This allows us to ensure that values passed to providers always conform to the provider's schema.
This wasn't used until now but we should enforce the schema consistency, especially when providers start generating their own rather than having it done by helper/schema. These will be presented as a warning initially to prevent any unexpected breakage.
5b56d40
to
23a36cf
Compare
Rebased to squash a couple commits, hopefully the last cleanup for this PR |
I'm still not completely happy with the validation concessions we need here. |
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. |
Due to both the nature of dynamic blocks, and the need for resources to
sometimes communicate incomplete values, we cannot validate
MinItems
andMaxItems
during decoding or inCoerceValue
.Since we're reducing the early automatic validation, add a
Block.Validate
method to precisely validate values. The number of items in theblock will be validated once the values is wholly known.
If a
NestingGroup
block has anyRequiredAttributes
, automaticallyinstantiating that would create a block missing those required
attributes, which will fail with the new validation. This means that the
block itself is essentially required, which we can enforce early in
InternalValidate
.Since nothing currently makes use of
NestingGroup
, we can change thesemantics slightly to better align with the validation rules already present.
This also turns on
InternalValidate
for the schema. While the generated configschemafor existing providers should follow the expectations of
InternalValidate
, this willonly return warnings for the time being to avoid breaking any existing providers.
Fixes #22414