Skip to content

Duplicates allowed for parameters and values (or any HashMap) #510

Open
@SteveL-MSFT

Description

@SteveL-MSFT

Prerequisites

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

Summary

Due to default serde behavior, duplicates in deserializing a HashMap is not an error and last one wins. There is another crate serde_with that has a macro that prevents dupes, but it doesn't work if the property is an Option<>. Tried a few ways to resolve this, but couldn't find a solutiont hat doesn't include implementing a custom deserializer. Deferring this work.

Steps to reproduce

$configYaml = @'
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
variables:
  myVariable: foo
  myVariable: bar
resources:
- name: test
  type: Test/Echo
  properties:
    output: "[variables('myVariable')]"
'@

dsc config get -d $configYaml

Expected behavior

Should error that `myVariable` is defined more than once

Actual behavior

`myVariable` takes the last set value

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.0-preview.3
PSEdition                      Core
GitCommitId                    7.5.0-preview.3
OS                             Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

dsc 3.0.0-preview.8

Visuals

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions