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

Schema validation fails when using expression #292

Closed
3 tasks done
SteveL-MSFT opened this issue Jan 5, 2024 · 3 comments
Closed
3 tasks done

Schema validation fails when using expression #292

SteveL-MSFT opened this issue Jan 5, 2024 · 3 comments
Labels
Resolution-Fixed The issue is fixed

Comments

@SteveL-MSFT
Copy link
Member

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

As part of #291, discovered that if you have a schema that limits property values (like OSInfo resource), then you can't use an expression that would resolve to a valid value since schema validation happens before expression execution.

Expected behavior

Expressions should be executed before schema is validated

Actual behavior

Schema is validated before expression execution

Error details

No response

Environment data

NA

Version

dsc 3.0.0-alpha.5

Visuals

No response

@SteveL-MSFT SteveL-MSFT self-assigned this Jan 5, 2024
@SteveL-MSFT SteveL-MSFT added this to the FeatureComplete for 3.0 milestone Jan 5, 2024
@michaeltlombardi
Copy link
Collaborator

This is an interesting problem, because we don't have control over the JSON schemas for the resources, and we do want to pre-validate as much as possible. I think we need to update the implementation so that it always accepts a valid expression for a value in the pre-validation phase, and always re-validates the property bag before calling the resource (optimally, only if it uses an expression, instead of double-validating static values) itself.

I'm not sure how to do that in a way that will work with general schema validation tooling except to define a dialect for the schema to use. I bring this up mostly because of the authoring experience - I'm not sure I see a way to avoid errors and warnings when authoring a configuration without the schema itself supporting the use of expressions in place of validated values.

@SteveL-MSFT
Copy link
Member Author

I would certainly prefer a way to perform static validation before we run any code, but dynamically modifying resource schema seems like a recipe for disaster. For now, my intent is to perform validation after expression invocation before calling the resource, but that means resources may run but validation can fail later leaving in an undesired state.

@SteveL-MSFT
Copy link
Member Author

Fixed via #294

@SteveL-MSFT SteveL-MSFT added the Resolution-Fixed The issue is fixed label Jan 19, 2024
@SteveL-MSFT SteveL-MSFT removed their assignment Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Fixed The issue is fixed
Projects
None yet
Development

No branches or pull requests

2 participants