New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Union() issues with 0.25.3 #13247
Comments
As a quick workaround on this if you need to unblock a build, the param test naming = any(union(defaultNaming, resourceNaming)) Working on fixing type inference for the |
Same here, we fixed it using the previous version @vlahane Can you share the other issue that we have? If is not related we should open a different github issue |
seems like similar issue but without union as well as with union function. Below are the simplified tests for existing bicep our code. Test-1bicep build result//resource.bicep
param location string
param accessPolicies object[]
resource akv 'Microsoft.KeyVault/vaults@2023-07-01' = {
location: location
name: 'myakv'
properties: {
sku: {
family: 'A'
name: 'standard'
}
tenantId: 'xxxxxxxx-86xx-xxxx-91xx-xx7cd011dxxx'
accessPolicies: accessPolicies
}
} Test-2bicep build result//dependencies.bicep
type accessPoliciesObj = {
objectId: string
permissions: object?
}
param location string
param accessPolicies accessPoliciesObj[]
resource akv 'Microsoft.KeyVault/vaults@2023-07-01' = {
location: location
name: 'myakv'
properties: {
sku: {
family: 'A'
name: 'standard'
}
tenantId: 'xxxxxxxx-86xx-xxxx-91xx-xx7cd011dxxx'
accessPolicies: accessPolicies
}
}
//resource.bicep
//hint: looks like not able to typecast to accessPoliciesObj type in new bicep version i.e. 0.25.3
param accessPolicies object[]
module test 'dependencies.bicep' = {
name: 'test-module'
params: {
accessPolicies: accessPolicies
location: 'eastus'
}
}
error in Test-2 and we have been using the same code in our projectresouces.bicep(7,5) : Error BCP035: The specified "object" declaration is missing the following required properties: "objectId". |
+1 this is a big bug. |
please make sure it'll work with map: map(items(_object), x=> union({ id: x.key }, x.value)) |
…s an additional properties type (#13272) Resolves #13247 The type narrowing on objects introduced in #12798 will erroneously raise a missing property diagnostic if the assigned value does not have an explicit property defined for each of the target's required properties, even if the assigned value allows additional properties. This PR updates the type narrowing to consider required properties not to be missing if the assigned value allows arbitrary additional properties. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/13272)
shouldn't we add support for explicit type casting as well in future? something like below? import { accessPoliciesObjType } from './types.bicep'
param myPolicies object[]
module test 'dependencies.bicep' = {
name: 'test-module'
params: {
accessPolicies: accessPoliciesObjType(myPolicies) //explicit type casting
location: 'eastus'
}
} |
Our Azure DevOps Pipeline started popping this error today after no changes to the bicep files. We figured there'd been an update that broke existing behavior. For us, we simply read in a list of tags on the containing resource group and union them with a locally defined list of tags. Previously, this code worked: All the mention of "types" in this issue clued me in on what to look for. Knowing that there's a Interestingly, we use this exact tag union code three different times in our main.bicep, but only the first two uses errored out. The two erroring modules are two version newer than the non-failing module, so I expect that upon review, we'll find some defect in those modules that this error has brought to our attention. TLDR: Using the |
Bicep version
0.25.3
Describe the bug
We use the Union() function a lot to merge a resource specific naming object with a general naming for all resources. Since 0.25.3 this gives us an error for all properties that aren't optional as you can see below.
To Reproduce
The error that we receive in this case is:
As you can see function is the only required property in this user defined object, and is the one causing trouble. However, if I require other properties, they also add to the list.
The text was updated successfully, but these errors were encountered: