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

fix(core): input validation for module templates #4995

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

thsig
Copy link
Collaborator

@thsig thsig commented Aug 29, 2023

What this PR does / why we need it:

Before this fix, we weren't performing a partial resolution pass on module template inputs before validating them against the input schema. This looks like it was a simple oversight (there's definitely no point in partially resolving an always-empty object).

This would result in validation errors e.g. when the schema declares a boolean field but the unresolved template is still a string value.

Which issue(s) this PR fixes:

Fixes #4946.

Special notes for your reviewer:

While looking at the code around input resolution and validation, I noticed that we never apply the input schema (as defined in e.g. schema.json) against the fully resolved inputs.

It looks like the idea here is to allow the user to pass through template strings that reference e.g. runtime values, which get resolved later in the flow.

If that's the case, then this may cause some surprising behaviour, since a template string for an input value that's supposed to resolve e.g. to a number or a boolean will fail validation because it's still a (template) string. CC @edvald

If this is the way we intend it to be, we should mention this wrinkle in our guide for config templates.

@thsig thsig force-pushed the module-template-default-value-validation-fix branch from b6fd177 to c86ffe8 Compare August 29, 2023 12:07
Before this fix, we weren't performing a partial resolution pass on
module template inputs before validating them against the input schema.

This would result in validation errors e.g. when the schema declares a
boolean field but the unresolved template is still a string value.
@thsig thsig force-pushed the module-template-default-value-validation-fix branch from c86ffe8 to 8ea8be1 Compare August 29, 2023 12:09
@thsig
Copy link
Collaborator Author

thsig commented Aug 29, 2023

Btw, thanks @shumailxyz for the excellent repro you posted on the issue!

Comment on lines +104 to 107
})
})
})
})

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah took me a while to realize that this whole diff is basically just nesting these tests under the ModuleResolver describe block.

Copy link
Contributor

@shumailxyz shumailxyz left a comment

Choose a reason for hiding this comment

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

@thsig Awesome! thanks for fixing this 👍

@shumailxyz shumailxyz added this pull request to the merge queue Aug 29, 2023
Merged via the queue into main with commit bb77681 Aug 29, 2023
41 checks passed
@shumailxyz shumailxyz deleted the module-template-default-value-validation-fix branch August 29, 2023 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.13: [Bug]: Conditional disabled flag is not working with default value
2 participants