config validate command needs to check for duplicate resource names in configuration document · Issue #842 · PowerShell/DSC · GitHub
Skip to content

config validate command needs to check for duplicate resource names in configuration document #842

Open

Description

@fl0p3k

Summary of the new feature / enhancement

In order to avoid errors at runtime, the dsc config validate should detect and provide appropriate error response when a resource name is duplicated in a configuration document.

Configuration:

{
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/config/document.json",
"resources": [
{
"type": "Microsoft.Windows/Registry",
"name": "EnsureTest1Value",
"properties": {
"keyPath": "HKEY_LOCAL_MACHINE\SOFTWARE\TEST",
"valueName": "Test1",
"valueData": { "DWord": 1 },
"_exist": true
}
},
{
"type": "Microsoft.Windows/Registry",
"name": "EnsureTest2Value",
"properties": {
"keyPath": "HKEY_LOCAL_MACHINE\SOFTWARE\TEST",
"valueName": "Test2",
"valueData": { "String": "Hello World!" },
"_exist": true
}
},
{
"type": "Microsoft.Windows/Registry",
"name": "EnsureTest1Value",
"properties": {
"keyPath": "HKEY_LOCAL_MACHINE\SOFTWARE\TEST",
"valueName": "Test",
"valueData": { "String": "Hello World!" },
"_exist": false
}
}
]
}

This below should return false with a reason as duplicate resource name

dsc config validate --file C:\dsc\Demo1.json
valid: true
reason: null

Proposed technical implementation details (optional)

No response

Activity

  1. SteveL-MSFT commented on May 28, 2025

    @SteveL-MSFT
    Member

    The validate sub-command is used by dsc itself to validate the input matches the JSONSchema. I can see how validate would be useful to users directly. I think what we should do is add a --schema-only to maintain the current behavior and update the group resource manifests to use this and add additional validation like duplicate resource names to this sub-command eventually having more static analysis capabilities.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions