Skip to content
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

Passing untyped objects to parameters with custom types no longer works in 0.25.3 #13281

Closed
mattias-fjellstrom opened this issue Feb 9, 2024 · 3 comments

Comments

@mattias-fjellstrom
Copy link

Bicep version
Bicep CLI version 0.25.3 (8627085)

Describe the bug
After upgrading to 0.25.3 we discovered that passing in an untyped object to a parameter with a custom type no longer works, even if the untyped object has the required fields. Bicep produces an error directly in the editor if you try this.

To Reproduce
The following sample code mimics a setup we have been using successfully up until and including 0.24.24.

Create main.bicep:

module data 'data.bicep' = {
  name: 'data-module'
}

module app 'app.bicep' = {
  name: 'app-module'
  params: {
    identity: data.outputs.identity
  }
}

Create data.bicep:

resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
  name: 'my-identity'
}

output identity object = union(identity, { name: identity.name, id: identity.id })

Create app.bicep:

param identity {
  id: string
}

output id string = identity.id

In main.bicep you now have an error The specified "object" declaration is missing the following required properties: "id".bicep(BCP035):

image

The output from data.bicep is an untyped object with the following shape:

{
  "outputs": {
    "identity": {
      "type": "Object",
      "value": {
        "apiVersion": "2023-01-31",
        "condition": true,
        "existing": false,
        "id": "/subscriptions/<redacted>/resourceGroups/rg-identity/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-identity",
        "isAction": false,
        "isConditionTrue": true,
        "isExtensibleResourceReference": false,
        "isTemplateResource": false,
        "location": "swedencentral",
        "name": "my-identity",
        "properties": {
          "clientId": "<redacted>",
          "principalId": "<redacted>",
          "tenantId": "<redacted>"
        },
        "provisioningOperation": "Read",
        "referenceApiVersion": "2023-01-31",
        "resourceGroup": "rg-identity",
        "resourceGroupName": "rg-identity",
        "resourceId": "Microsoft.ManagedIdentity/userAssignedIdentities/my-identity",
        "scope": "",
        "subscriptionId": "<redacted>",
        "tags": {}
      }
    }
  }
}

Was this intentionally broken? Perhaps it was a bug that this was allowed, and now the bug is fixed? :)

Additional context
We are using this pattern a lot where we have "data modules" that expose various resources in similar ways. We use union(<resource>, { name: <resource>.name, id: <resource>.id }) since in general the id and name properties are not included otherwise.

@slavizh
Copy link
Contributor

slavizh commented Feb 9, 2024

+1

@cedricbraekevelt
Copy link

I have already reported this over here #13247

@mattias-fjellstrom
Copy link
Author

Fixed by #13272, thanks @cedricbraekevelt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants