fix: accept unresolved references in schema_validation#9496
Open
ameyypawar wants to merge 1 commit into
Open
Conversation
When a script enables `// schema_validation` and has a parameter typed as a resource (or any object), running it with that parameter supplied as a Windmill reference failed with `Argument XX should be an object`. Schema validation runs before the worker resolves references, so a `$res:` (or `$var:`/`$jsonvar:`/`$encrypted:`) reference is still a string at validation time and was rejected by the object rule. Short-circuit `apply_rule` to accept unresolved reference strings regardless of the declared type; the worker resolves them to their real value after validation. Fixes windmill-labs#6938
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When a script enables
// schema_validationand has a parameter typed as a resource (or any object), executing it with that parameter supplied as a Windmill reference fails:Schema validation runs before the worker resolves references, so a
$res:…(or$var:/$jsonvar:/$encrypted:) reference is still a string at validation time and is rejected by the object rule.Changes
windmill-common/src/schema.rs:SchemaValidationRule::apply_rulenow short-circuits when the value is an unresolved reference string ($var:/$jsonvar:/$res:/$encrypted:— the prefixes the worker resolves), accepting it regardless of the declared type. The worker resolves the reference to its real value after validation runs.validate_accepts_unresolved_reference_for_object_param) covering all four reference prefixes, a genuine object (still validates), and a plain non-reference string (still rejected).Test plan
cargo test -p windmill-common validate_accepts_unresolved_reference_for_object_param// schema_validationscript with a resource parameter) and run it with the resource selected; confirm no "should be an object" error.Fixes #6938
Summary by cubic
Allow unresolved Windmill references during schema validation so object/resource params passed as
$res:/$var:/$jsonvar:/$encrypted:no longer fail with "should be an object". The worker resolves these after validation. Fixes #6938.SchemaValidationRule::apply_ruleto accept$var:,$jsonvar:,$res:,$encrypted:strings for any declared type.Written for commit 5752869. Summary will update on new commits.