Skip to content

Fix allowing empty string to be passed to resources#1544

Open
SteveL-MSFT wants to merge 3 commits into
PowerShell:mainfrom
SteveL-MSFT:empty-string
Open

Fix allowing empty string to be passed to resources#1544
SteveL-MSFT wants to merge 3 commits into
PowerShell:mainfrom
SteveL-MSFT:empty-string

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

@SteveL-MSFT SteveL-MSFT commented May 23, 2026

PR Summary

The existing code always tries to parse a string as an expression and handles specific cases where it fails to have it as a literal. In the case like an empty string, the parser fails immediately so there's no chance to pass an empty string.

The fix checks if the trimmed statement is empty and if so, passes it back as a string literal instead of trying to parse.

PR Context

Fix #1542

Copy link
Copy Markdown
Contributor

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 updates the DSC expression parser to allow empty-string property values to flow through expression evaluation without failing parsing, addressing #1542.

Changes:

  • Treat a tree-sitter root parse error as a literal string value instead of a parser error.
  • Add a Pester test validating that an empty string property value is preserved through dsc config get.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/dsc-lib/src/parser/mod.rs Adjusts root-node parse error handling so empty strings can be passed as literal values.
dsc/tests/dsc_expressions.tests.ps1 Adds coverage for empty-string property values during expression evaluation.

Comment thread dsc/tests/dsc_expressions.tests.ps1 Outdated
Comment thread lib/dsc-lib/src/parser/mod.rs Outdated
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.

Cannot pass empty string as property value for WindowsPowerShell adapted resource

2 participants