DSC
DSC copied to clipboard
Document schema requires 1 item in resources array
Prerequisites
- [x] Write a descriptive title.
- [x] Make sure you are able to repro it on the latest version
- [x] 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
- Have a resource (
ResourceWithNoState) that canexportwith 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). - 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