Skip to content

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

Open
sean0407 wants to merge 1 commit into
PowerShell:mainfrom
sean0407:codex/issue-1736-schema-exit-code
Open

sean0407 wants to merge 1 commit into
PowerShell:mainfrom
sean0407:codex/issue-1736-schema-exit-code

Conversation

@sean0407

Copy link
Copy Markdown

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 Registry 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. Regression tests cover both mappings and the reported input.
  • 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
Author

@microsoft-github-policy-service agree

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.

$log | Should -Match ".*Resource named 'MyTest' for type 'Microsoft.DSC.Debug/Echo' is specified more than once.*" -Because ($log | Out-String)
}

It 'Schema validation failures return exit code 5' -Skip:(!$IsWindows) {

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.

Can you change this test to use the Echo resource instead so it works cross-platform?

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.

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

3 participants