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

`directives.version` is checked against dsc-lib's crate version (3.2.0), not the running dsc version

Đang mở
#1,735 1 bình luận 1 reaction 1 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ó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
powershell, rust
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu tại lib/dsc-lib/src/configure/mod.rs quanh L1299-L1301 (validate_config), nơi env!("CARGO_PKG_VERSION") được phân tích, và so sánh với mã siêu dữ liệu tại L1253-L1257 dùng self.context.dsc_version — cách sửa là khiến phép kiểm tra chỉ mục (directive) dùng phiên bản dsc đang chạy thay vì phiên bản của crate. Sau đó mở rộng dsc/tests/dsc_version.tests.ps1, với các trường hợp hiện tại (=999.0.0, >=3.1) đều đạt ở cả hai cách, thêm một trường hợp phân biệt 3.2.0 với phiên bản đang chạy (ví dụ: ghim '='). Xong nghĩa là ghim phiên bản đang chạy thành công và ghim 3.2.0 thất bại trên dsc mới hơn, được xác minh bằng cách chạy bài kiểm tra Pester.

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

Mô tả

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

directives.version always compares against 3.2.0, whatever dsc build is running. On dsc 3.3.0, pinning '=3.3.0' fails and pinning '=3.2.0' passes. 3.4.0-preview.1 behaves the same way.

In practice you can't require anything newer than 3.2.0 with the directive, and an upper bound such as '<3.3.0' is accepted by 3.3.0 and 3.4.0-preview.1.

The check in validate_config parses env!("CARGO_PKG_VERSION"), and inside dsc-lib that resolves to dsc-lib's own version (mod.rs L1299-L1301 at v3.3.0). lib/dsc-lib/Cargo.toml is still 3.2.0 on main, while dsc/Cargo.toml is 3.4.0-preview.1. The metadata code in the same file uses self.context.dsc_version (L1253-L1257), so the directive check could probably use that as well. The existing tests in dsc/tests/dsc_version.tests.ps1 use =999.0.0 and >=3.1, and both give the same result with 3.2.0 or 3.3.0, so they don't catch this.

Steps to reproduce
  1. Save this as repro.dsc.config.yaml:

    $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
    directives:
      version: '=3.3.0'
    resources:
    - name: os
      type: Microsoft/OSInfo
      properties: {}
    
  2. Run it with dsc 3.3.0:

    dsc --version
    dsc config test --file ./repro.dsc.config.yaml
    
  3. Change the directive to '=3.2.0' and run dsc config test again.

Expected behavior
PS> dsc --version
dsc 3.3.0

# version: '=3.3.0'
exit code 0, test results for the OSInfo instance

# version: '=3.2.0'
ERROR Error: Validation: Configuration requires DSC version '=3.2.0', but the current version is '3.3.0'
exit code 2
Actual behavior
PS> dsc --version
dsc 3.3.0

# version: '=3.3.0'
ERROR Error: Validation: Configuration requires DSC version '=3.3.0', but the current version is '3.2.0'
exit code 2

# version: '=3.2.0'
exit code 0, and the output reports executionInformation.version: 3.3.0

Same document, other requirements:

directives.version dsc 3.3.0 dsc 3.4.0-preview.1
=<running version> exit 2 exit 2
=3.2.0 exit 0 exit 0
<3.3.0 exit 0 exit 0
>=3.3.0 exit 2 not run
Error details
2026-10-04T10:25:47.660394Z ERROR Error: Validation: Configuration requires DSC version '=3.3.0', but the current version is '3.2.0'
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. dsc 3.3.0 installed from the release msixbundle; 3.4.0-preview.1 run from the release zip.

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.