You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for expressions as command resource args in resource manifest - #1788
Add new ExpressionArg as valid arg type within a resource manifest (including Actions), only supported for get, set, test, and export
Created helper function to process ExpressionArg used for both resources and actions
Add new properties() function to retrieve the current properties which is used with an ExpressionArg
Since the current properties are stored within the current context, move target_resource and execution_type to be retrieved from context and update all internal functions that used to have them as separate parameters to simply pass and use the context (this is the bulk of the changes across the many files)
cleanup DscManager noticing that the resource functions aren't being used since if you have the DscResource, you can invoke it directly so removed them.
cleanup some commented out code from the Actions PR that is not needed
separate out is_secure_value() and contains_secure_value() for different purposes
Because a property can be optional, if the expression evaluation fails (like due to dot accessing an optional property that wasn't specified), then if that arg is NOT mandatory, then this error is written as a debug message and ignored.
Adds expression-based command arguments to DSC resource and action manifests, addressing #1722 by letting manifests derive arguments from resource properties without JSON-processing wrappers.
Changes:
Adds expression argument types, shared evaluation logic, and the properties() function.
Passes operation context through resource, action, adapter, CLI, server, and Bicep invocation paths.
Adds test fixtures and coverage, and removes unused manager wrappers and commented-out code.
File
Description
tools/test_group_resource/src/main.rs
Updates fixtures for target-resource state relocation.
tools/dsctest/src/main.rs
Dispatches expression-argument tests and schema output.
tools/dsctest/src/expression_arg.rs
Defines the expression-argument test model.
tools/dsctest/src/args.rs
Adds expression-related test command arguments.
tools/dsctest/src/action.rs
Returns evaluated expression values in action output.
tools/dsctest/dsctest.dsc.manifests.json
Adds resource and action expression fixtures.
lib/dsc-lib/src/resources/resource_invoke.rs
Updates invocation interfaces and adds shared expression evaluation.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Property-dependent schemas can reuse an incorrect cached schema, supported array export filters are rejected, and the new set test does not exercise set-expression argument handling.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Expression evaluation can expose nested secure property values in trace logs even when only a non-sensitive property is accessed.
No open issues 🎉
6 previously missed issues
In code that hasn't changed since last review
Recursively redact secure values in expression trace logs
lib/dsc-lib/src/functions/properties.rs:32
This returns the entire properties object to the expression evaluator, whose pre-accessor trace logging in parser/expressions.rs:131–135 only recognizes top-level secure wrappers. For properties such as {name: "public", password: {secureString: "secret"}}, even evaluating properties().name logs the password before applying the accessor. Apply recursive redaction to the evaluator's logged values, including accessor results, while preserving the actual values returned to the command.
Pass resource properties to config validation
dsc/src/subcommand.rs:534
config validate now supplies a context, but it never sets the resource-block properties. When a manifest implements validation using an expression argument such as mandatory [properties().name], validate_properties forwards this empty context to the validate command, rejecting a configuration that supplies name. Populate the context with this block's properties before validating it.
Allow expression-only actions to opt out of stdin
lib/dsc-lib/src/actions/dscaction.rs:281
Expression-only actions still receive the full input JSON on stdin, even when their executable reads only command arguments. With sufficiently large input and output, this can deadlock because run_process_async finishes writing stdin before draining stdout. Add an explicit stdin opt-out while preserving actions that intentionally combine expression arguments with stdin.
Clear filtered properties from the export expression context
lib/dsc-lib/src/configure/mod.rs:137
When export filtering is handled by the engine, resource_input is cleared but context.properties still contains the filter. An export argument such as [properties().name] therefore receives the engine-only filter even for a resource declaring supportsFiltering: false, while JSON-input arguments correctly receive no input. Clear properties in a scoped export context when stripping the filter, so expression arguments cannot pass it back to the resource.
Preserve copy-loop state during manifest argument evaluation
lib/dsc-lib/src/configure/mod.rs:612
Manifest arguments using [string(copyIndex())] fail for resources inside copy loops because get_properties clears the restored loop state before resource invocation. Preserve that state in an invocation-scoped context through manifest-argument evaluation, then clear it before processing the next resource.
Detect native what-if support without swallowing expression errors
An evaluation error is treated as absence of native what-if support, even when the manifest contains a whatIfArg. A failing mandatory expression therefore selects the dedicated/synthetic fallback instead of propagating the error; with a successful synthetic test, the dry run can report success for a broken native invocation. Detect support by inspecting the argument variants, then let processing the selected operation propagate mandatory-expression errors.
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
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.
PR Summary
ExpressionArgas valid arg type within a resource manifest (including Actions), only supported forget,set,test, andexportExpressionArgused for both resources and actionsproperties()function to retrieve the current properties which is used with anExpressionArgpropertiesare stored within the currentcontext, movetarget_resourceandexecution_typeto be retrieved fromcontextand update all internal functions that used to have them as separate parameters to simply pass and use thecontext(this is the bulk of the changes across the many files)DscManagernoticing that the resource functions aren't being used since if you have theDscResource, you can invoke it directly so removed them.is_secure_value()andcontains_secure_value()for different purposesBecause a property can be optional, if the expression evaluation fails (like due to dot accessing an optional property that wasn't specified), then if that arg is NOT mandatory, then this error is written as a debug message and ignored.
PR Context
Fix #1722