Skip to content

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Aug 6, 2025

PR Summary

The problem is when it comes to implicit use of adapted resources, the DSC engine internally creates a Configuration and executes that. However, the outer Configuration has already had expressions parsed so that [[this is a string literal] becomes [this is a string literal] and the nested configuration tries to parse that again and fails because it's invalid. The change is to have a new property on the Configurator indicating whether to process expressions and only in the case of a dynamically created Configurator for implicit adapted resources do we want to NOT process them as it was already processed by the parent Configurator.

This change adds a new property to Context to indicate whether parse_and_execute() should process the expression or simply return the string back.

Some tests unrelated to this change were found to be wrong and fixed.

PR Context

Fix #1024

@SteveL-MSFT SteveL-MSFT requested review from tgauth and Copilot August 6, 2025 20:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes expression parsing for adapted resources by preventing double processing of DSC expressions. When adapted resources are used implicitly, the DSC engine creates a nested Configuration which attempts to re-parse expressions that were already processed by the parent Configuration, causing failures with string literals like [[this is a string literal].

  • Adds a process_expressions flag to the Configurator to control expression processing
  • Updates parse_and_execute() to accept a boolean parameter that bypasses expression processing when false
  • Modifies adapted resource handling to disable expression processing for dynamically created configurators

Reviewed Changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dsc_lib/src/parser/mod.rs Core parser changes to add process_expressions parameter and early return logic
dsc_lib/src/configure/mod.rs Adds process_expressions field to Configurator and updates all expression parsing calls
dsc_lib/src/dscresources/dscresource.rs Sets process_expressions to false for adapted resource configurations
dsc_lib/src/configure/depends_on.rs Updates dependency parsing calls to use new parameter
Test files Updates all unit tests to pass true for the new process_expressions parameter
powershell-adapter/Tests/ Adds integration test and supporting test resource for the fix
dsc_lib/locales/en-us.toml Adds localization string for debug message

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Aug 7, 2025
Merged via the queue into PowerShell:main with commit 2c87561 Aug 7, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the not-parse-again branch August 7, 2025 14:39
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.

Parser throws error on [
2 participants