Skip to content

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

Description

@SamyRai

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

The CLI reference says exit code 5 means "a resource definition or instance value was invalid against its JSON schema". When a resource instance fails schema validation, dsc exits with 2.

EXIT_VALIDATION_FAILED is still defined in dsc/src/util.rs L73 but nothing uses it, on v3.3.0 or main. Its last use was exit(EXIT_VALIDATION_FAILED) in config validate, removed in 8fff4fbb ("fix merge conflict", 2024-07-25). It looks like that was a side effect of the merge rather than a decision, but I couldn't confirm it.

The same table lists only codes 0 to 6, while util.rs also defines 7 (resource not found), 8 (assertion failed), 9 (server failed) and 10 (Bicep failed).

I don't know which side you'd rather change: return 5 for schema validation errors, or drop 5 from the docs (and add 7 to 10). Either works for me. I script against the exit codes and only need the docs and the binary to agree.

This is not the same as #817 or #1245, which are about exit codes coming back from resources.

Steps to reproduce

  1. Save this as repro.dsc.config.yaml. The property name has a typo (valuName). config test doesn't write anything, so the key is never created:

    $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
    resources:
    - name: typo in property name
      type: Microsoft.Windows/Registry
      properties:
        keyPath: HKCU\Software\DscExitCodeRepro
        valuName: Example
  2. Run:

    dsc config test --file ./repro.dsc.config.yaml
    $LASTEXITCODE

Expected behavior

ERROR Schema: Additional properties are not allowed ('valuName' was unexpected)
5

Actual behavior

ERROR Schema: Additional properties are not allowed ('valuName' was unexpected)
2

Other inputs on dsc 3.3.0:

Input Exit
unknown resource property (above) 2
wrong property type, valueData: { DWord: "x" } 2
same two cases with dsc resource test -r Microsoft.Windows/Registry 2
unknown top-level key in the document 2
invalid YAML 4
parameter default above its maxValue 4

Error details

2026-10-04T10:25:51.959520Z ERROR Schema: Additional properties are not allowed ('valuName' was unexpected)

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.26100.9444
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.9444
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Windows 11 Pro for Workstations 25H2, build 26200.

Version

3.3.0 (also reproduced on 3.4.0-preview.1)

Visuals

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions