fix: return validation exit code for schema failures by sean0407 · Pull Request #1754 · PowerShell/DSC · GitHub
Skip to content

fix: return validation exit code for schema failures - #1754

Merged
Steve Lee (SteveL-MSFT) merged 3 commits into
PowerShell:mainfrom
sean0407:codex/issue-1736-schema-exit-code
Oct 21, 2026
Merged

Steve Lee (SteveL-MSFT) merged 3 commits into
PowerShell:mainfrom
sean0407:codex/issue-1736-schema-exit-code

Conversation

@sean0407

@sean0407 sean0407 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

config test
  schema validation error -> exit 5
  other execution error -> exit 2

Evidence

  • Before: Exit code 5 is documented for schema validation failures but never returned (schema errors exit with 2) #1736 reports that dsc config test returns 2 for an unknown resource property. config_test maps every invoke_test error to EXIT_DSC_ERROR; schema validation errors arrive as DscError::Schema.
  • After: config_test maps DscError::Schema to the existing EXIT_VALIDATION_FAILED value (5), while other errors retain code 2. The regression test asserts exit code 5 and the unexpected-property diagnostic for outpt on Echo.
  • Linux ARM64, PowerShell 7.6.7 / Pester 6.2.0: targeted Schema validation failures return exit code 5 test passed (1 passed, 0 failed).
  • git diff --check: passed. Patch policy accepted 2 files with no binary changes.

Merge Danger

Door: two-way

Blast Radius: narrow

Only the exit status for schema errors returned by dsc config test changes; other errors keep their current code.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 18:11
@sean0407

Copy link
Copy Markdown
Contributor Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow change preserves other error mappings and includes targeted unit and regression coverage.

0 open findings

What changed in this PR

Aligns dsc config test schema-error exit codes with the documented behavior reported in #1736.

Changes:

  • Returns exit code 5 for schema errors while preserving code 2 for other execution errors.
  • Adds Rust mapping tests and a Windows Registry regression test.
File Description
dsc/​tests/​dsc_config_test.tests.ps1 Tests exit code 5 for an invalid Registry property.
dsc/​src/​subcommand.rs Maps schema errors to exit code 5 and tests both mappings.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread dsc/tests/dsc_config_test.tests.ps1 Outdated
@SteveL-MSFT Steve Lee (SteveL-MSFT) added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 20, 2026

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to create a file as the yaml can be passed as an arg

Comment thread dsc/tests/dsc_config_test.tests.ps1 Outdated
@SteveL-MSFT
Steve Lee (SteveL-MSFT) added this pull request to the merge queue Oct 21, 2026
Merged via the queue into PowerShell:main with commit fadea80 Oct 21, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exit code 5 is documented for schema validation failures but never returned (schema errors exit with 2)

3 participants