PSRule.Rules.Azure
PSRule.Rules.Azure copied to clipboard
[BUG] PSRule not handling optionality marker ? as expected
Existing rule
No response
Description of the issue
It looks to me that PSRule is not capable of handling the optionality marker ?
properly. The marker is used whether if a property is required or not on a user-defined type most commonly, however it can also be used with a parameter, to specify if it is a required parameter or not.
@description('Route table configuration.')
param parRouteTable typRouteTable?
Error messages
2024-02-21T17:33:28.3000658Z ##[error]Failed to expand bicep source '/home/runner/work/platform/platform/./deployments/sub/mgmt-env-001/parameters/main.dev.bicepparam'. Exception calling "GetBicepParamResources" with "2" argument(s): "Unable to expand resources because the source file '/home/runner/work/platform/platform/./deployments/sub/mgmt-env-001/parameters/main.dev.bicepparam' was not valid. The type for parameter 'parRouteTable' was not defined or invalid."
Reproduction
main.dev.bicepparam
using '../main.bicep'
param parEnvironment = 'dev'
main.bicep
@description('Route table configuration.')
param parRouteTable typRouteTable?
@description('This module will deploy the base infrastructure required for any subscriptions.')
module modPtnWrapper './src/deploy.bicep' = {
name: 'modPtnWrapper-${parBaseTime}'
params: {
parRouteTable: parRouteTable
}
}
deploy.bicep (nested module in main.bicep)
@description('The custom routes to deploy.')
param parRouteTable typRouteTable?
Version of PSRule
2.9.0
Version of PSRule for Azure
1.33.2
Additional context
I was unsure whether if the issue should he here or in the PSRule repository.
@BenjaminEngeset Are you able to provide typRouteTable
can't repo this currently. Generally nullable parameters and types are supported and should work.
Are you using imports at all? Currently this doesn't work #2537
@BenjaminEngeset Are you able to provide
typRouteTable
can't repo this currently. Generally nullable parameters and types are supported and should work.Are you using imports at all? Currently this doesn't work #2537
I forgot to mention, I am exporting the type from deploy.bicep and importing the type into main.bicep. Makes sense, I expect this is the issue then instead of what I thought.
When do you think we can expect having this feature implemented?
@BenjaminEngeset Support will ship with v1.34.0, which should ship next week. But feel free to checkout the next pre-release.
Closing as duplicate of #2537