Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,736 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu tại dsc/src/util.rs quanh L73 nơi EXIT_VALIDATION_FAILED (5) được định nghĩa và lần theo những đường thực sự gọi exit() cho lỗi kiểm thử schema, so sánh với đường exit(2) mà repro chạm tới. Tái hiện với dsc config test --file repro.dsc.config.yaml từ issue và kiểm tra nơi thông báo ERROR Schema được phát (có thể trong xử lý lệnh config/resource trong dsc/src). Xong nghĩa là lỗi schema trả về 5 kèm một test khẳng định điều đó, hoặc hằng không dùng bị xóa và bảng exit-code khớp với util.rs — xác nhận với maintainer nên đổi bên nào trước.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Rust
Star
532
Fork
76
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PowerShell/DSC

Tất cả issue của PowerShell/DSC

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.