You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.jsonvariables: myVariable: foo myVariable: barresources:- 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 120: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
The text was updated successfully, but these errors were encountered:
This could be resolved okay with a note in the documentation - fwiw, users who are defining their configuration documents in VS Code with the YAML extension will get author-time feedback that an object can't define the same property twice, so even though DSC isn't currently raising an error, the user has some way to know that defining the same key twice in an object isn't supported.
Agree this could just be doc'd so we can focus on other items. I already spent too much time trying to figure out how to get it to not accept dupes, but existing solutions I found only worked if it wasn't an Option<> which is needed in our case.
Prerequisites
Summary
Due to default
serde
behavior, duplicates in deserializing aHashMap
is not an error and last one wins. There is another crateserde_with
that has a macro that prevents dupes, but it doesn't work if the property is anOption<>
. 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
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
Version
dsc 3.0.0-preview.8
Visuals
No response
The text was updated successfully, but these errors were encountered: