PowerShell / PowerShell/DSC

Document schema requires 1 item in resources array

Open
#717 0 comments 0 reactions 1 assignee View on GitHub

@michaeltlombardi is already working on this.

Since Mar 24, 2025.

Issue-Bug Schema-Impact
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

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

The document schema requires 1 item in the resources array, but dsc.exe will accept and generate documents with an empty resources array.

https://github.com/PowerShell/DSC/blob/d769405dc3cc70f8c8baaf2b4708b47aacdabe00/schemas/v3.0.0/config/document.json#L42-L46

The minItems should be either removed or set to 0.

Steps to reproduce
  1. Have a resource (ResourceWithNoState) that can export with no state configured so that it produces no output (or just create a resource manifest with export and point it at an executable that will produce no output).
  2. Run dsc resource export -r ResourceWithNoState
# Output from: dsc resource export -r ResourceWithNoState

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
contentVersion: 1.0.0
resources: []

Piping that back into dsc like dsc resource export -r ResourceWithNoState | dsc config test -f - also succeeds:

# Output from: dsc resource export -r ResourceWithNoState | dsc config test -f -

metadata:
  Microsoft.DSC:
    version: 3.0.0
    operation: test
    executionType: actual
    startDatetime: 2025-03-20T14:35:37.857292600-07:00
    endDatetime: 2025-03-20T14:35:46.704326700-07:00
    duration: PT8.8470341S
    securityContext: restricted
results: []
messages: []
hadErrors: false

PS Another bonus issue: dsc searches all adapters for resources despite not needing to find any, leading to this empty test taking anywhere from 6 to 28 seconds.

Expected behavior
The schema definition for resources matches the observed behavior which has no minimum item requirement.
Actual behavior
An empty resources array is allowed, but the schema requires 1 item.
Error details

Environment data
N/A
Version

3.0.0

Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.