Closed joshcorr closed 1 week ago
You're correct, the JSON Schema forbids non-integers for the property names in the definition of exitCodes
:
The implementation for DSC expects the exit codes to be an integer:
You can add the following repro manifest to your path to see how DSC behaves:
{
"$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.json",
"type": "DSC.Repro/Example",
"version": "0.1.0",
"description": "Repro behavior when exit codes are hexadecimal.",
"get": {
"executable": "repro",
"input": "stdin"
},
"schema": {
"command": {
"executable": "repro",
"args": [
"--schema"
]
}
},
"exitCodes": {
"0": "Success",
"1": "Error",
"-2147024891": "testing hexadecimal as integer"
}
}
dsc resource list DSC.Repro/Example
dsc resource list DSC.Repro/Example
| ConvertFrom-Json
| Select-Object -ExpandProperty manifest
| Select-Object -ExpandProperty exitCodes
| ConvertTo-Json
Type Kind Version Caps RequireAdapter Description
-------------------------------------------------------------------------------------------------------------
DSC.Repro/Example Resource 0.1.0 g----- Repro behavior when exit codes are hexadecimal.
{
"0": "Success",
"1": "Error",
"-2147024891": "testing hexadecimal as integer"
}
However, if you update the manifest to use hex format for the exit code:
{
// ... rest of the manifest
"exitCodes": {
"0": "Success",
"1": "Error",
"-2147024891": "testing hexadecimal as integer",
"0x80070005": "testing hexadecimal as hex format"
}
}
DSC raises an error - it doesn't have any built-in handling for converting the string 0x80070005
into the integer -2147024891
when reading in the JSON to the struct.
dsc resource list DSC.Repro/Example
2024-04-17T14:28:27.325654Z WARN Manifest: C:\code\pwsh\DSCv3\bin\debug\repro.dsc.resource.json
JSON: expected `"` at line 22 column 11
Type Kind Version Caps RequireAdapter Description
------------------------------------------------------
I can definitely update the schema definitions to allow negative integers, but unless the source code for DSC is updated, I can't update it to allow numbers in hexadecimal format.
Fixed by #410
Summary of the new feature / enhancement
While I was playing around an idea for a DSC Resource, I received Exit code
-2147024891
(0x80070005
) Access Denied when trying to execute a binary which required elevation. I tried to represent this error in theexitCodes
section of a DSC Resource manifest, but it does not appear to match the regex that dsc is using to validatedexitCodes
.The feature request is that the regex be updated to support negative/Hexidecimal exit codes.
Proposed technical implementation details (optional)
No response