Skip to content
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

helper/schema: remove outdated ValidateFunc restrictions #22298

Conversation

vancluever
Copy link
Contributor

Validation on non-primitives has possibly worked for several years -
see initial commit in 2a179d1, and subsequent blames associated with
respective lines in functions validateType, validateList, and
validatePrimitive.

For some reason though, we've never removed the restriction from
internalValidate.

This commit removes it, in addition to fixing the specific test case,
which was giving a false positive on the validation error as it was
missing the Elem attribute for TypeSet.

Validation on non-primitives has possibly worked for several years -
see initial commit in 2a179d1, and subsequent blames associated with
respective lines in functions validateType, validateList, and
validatePrimitive.

For some reason though, we've never removed the restriction from
internalValidate.

This commit removes it, in addition to fixing the specific test case,
which was giving a false positive on the validation error as it was
missing the Elem attribute for TypeSet.
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋
I'm a little bit worried about "opening the flood gates" without more thorough testing. I'm sure this works well for simple cases like set/list of strings (as demonstrated in the modified test), or other primitive types, but I'm not sure we have the right SDK API in place to provide any reasonable UX for validating deeply nested structures, i.e. cases where Elem is not a primitive type.

Technically it should just work, but I'd rather not expand the surface of the SDK for now, especially after the 0.12 work, which has left parts of this package practically untested.

For these reasons I'm tempted to close the PR, but I'm sure it's something we'd want to address eventually as part of our future work on the SDK, when we get to a point of better test coverage and feel safer to introduce such changes.

@radeksimko radeksimko added the waiting-response An issue/pull request is waiting for a response from the community label Aug 8, 2019
@vancluever
Copy link
Contributor Author

Hey Radek,

This is a fair concern.

Maybe we can compromise and allow it on primitive element types but not nested ones?

PS: It should be noted that the only thing preventing someone from using ValidateFuncs in this manner is InternalValidate, which is only called when using the acceptance test framework. It actually doesn't prevent the use in practice - you can sidestep it by just building the binary and not using the acceptance tests.

@vancluever
Copy link
Contributor Author

@radeksimko if you could weigh in on hashicorp/terraform-provider-tfe#86 (comment) that'd be great, as I'm kind of confused how what @lafentres is doing is working if we are still restricting this in InternalValidate?

@pselle pselle removed the waiting-response An issue/pull request is waiting for a response from the community label Aug 15, 2019
@vancluever
Copy link
Contributor Author

I'm going to close this. As per the aforementioned thread, this works just fine if you add the ValidateFunc to the individual element versus the actual TypeList/TypeSet.

@vancluever vancluever closed this Aug 17, 2019
@ghost
Copy link

ghost commented Sep 16, 2019

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.

@ghost ghost locked and limited conversation to collaborators Sep 16, 2019
@pselle pselle deleted the helper-schema-remove-outdated-validatefunc-restrictions branch November 13, 2019 19:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants