Check for previous/existing GitHub issues
Issue Type?
Bug
Description
With the current version of Bicep, the JSON template is rendered a bit differently and the check for UDTs/RDTs does not account for said way.
You can see the result here. The parameter does have a type and should now show up as incorrect.
The reason for the warnings that the check in the corresponding test
|
$hasProperties = $parameter.keys -contains 'properties' |
|
$hasRdtDefintion = $parameter.metadata.Keys -contains '__bicep_resource_derived_type!' |
|
$hasUdtDefinition = $parameter.keys -contains '$ref' |
Assumes that the parameter has a key $ref for UDTs (which is the way it used to be). However, at least in the latest version of bicep, the parameter (when debugging the right after the aforementioned lines shows the parameter as
{
"type": "object",
"discriminator": {
"propertyName": "kind",
"mapping": {
"Automatic": {
"$ref": "#/definitions/resourcePredictionsProfileAutomaticType"
},
"Manual": {
"$ref": "#/definitions/resourcePredictionsProfileManualType"
}
}
},
"nullable": true,
"metadata": {
"description": "Optional. Determines how the stand-by scheme should be provided."
},
"name": "resourcePredictionsProfile"
}
So now, there's a discriminator key with a mapping in it per each case. Each of those then must have a $ref or have a metadata key with the value __bicep_resource_derived_type!.
To test the last point, I expanded the type resourcePredictionsProfile like this to debug how it would look like for a resourceInput value.
resourcePredictionsProfile: (
| resourcePredictionsProfileAutomaticType
| resourcePredictionsProfileManualType
| resourceInput<'Microsoft.DevOpsInfrastructure/pools@2025-09-20'>.properties.agentProfile)?
Again, using the debugger, the previous JSON now looks like
{
"type": "object",
"discriminator": {
"propertyName": "kind",
"mapping": {
"Automatic": {
"$ref": "#/definitions/resourcePredictionsProfileAutomaticType"
},
"Manual": {
"$ref": "#/definitions/resourcePredictionsProfileManualType"
},
"Stateful": {
"type": "object",
"metadata": {
"__bicep_resource_derived_type!": "System.Management.Automation.OrderedHashtable"
}
},
"Stateless": {
"type": "object",
"metadata": {
"__bicep_resource_derived_type!": "System.Management.Automation.OrderedHashtable"
}
}
}
},
"nullable": true,
"metadata": {
"description": "Optional. Determines how the stand-by scheme should be provided."
},
"name": "resourcePredictionsProfile"
}
So the test must be updated accordingly. The above should be enough information to do so.
Check for previous/existing GitHub issues
Issue Type?
Bug
Description
With the current version of Bicep, the JSON template is rendered a bit differently and the check for UDTs/RDTs does not account for said way.
You can see the result here. The parameter does have a type and should now show up as incorrect.
The reason for the warnings that the check in the corresponding test
bicep-registry-modules/utilities/pipelines/staticValidation/compliance/module.tests.ps1
Lines 1075 to 1077 in 7fb8f74
Assumes that the parameter has a key
$reffor UDTs (which is the way it used to be). However, at least in the latest version of bicep, the parameter (when debugging the right after the aforementioned lines shows the parameter as{ "type": "object", "discriminator": { "propertyName": "kind", "mapping": { "Automatic": { "$ref": "#/definitions/resourcePredictionsProfileAutomaticType" }, "Manual": { "$ref": "#/definitions/resourcePredictionsProfileManualType" } } }, "nullable": true, "metadata": { "description": "Optional. Determines how the stand-by scheme should be provided." }, "name": "resourcePredictionsProfile" }So now, there's a
discriminatorkey with amappingin it per each case. Each of those then must have a$refor have a metadata key with the value__bicep_resource_derived_type!.To test the last point, I expanded the type
resourcePredictionsProfilelike this to debug how it would look like for aresourceInputvalue.Again, using the debugger, the previous JSON now looks like
{ "type": "object", "discriminator": { "propertyName": "kind", "mapping": { "Automatic": { "$ref": "#/definitions/resourcePredictionsProfileAutomaticType" }, "Manual": { "$ref": "#/definitions/resourcePredictionsProfileManualType" }, "Stateful": { "type": "object", "metadata": { "__bicep_resource_derived_type!": "System.Management.Automation.OrderedHashtable" } }, "Stateless": { "type": "object", "metadata": { "__bicep_resource_derived_type!": "System.Management.Automation.OrderedHashtable" } } } }, "nullable": true, "metadata": { "description": "Optional. Determines how the stand-by scheme should be provided." }, "name": "resourcePredictionsProfile" }So the test must be updated accordingly. The above should be enough information to do so.