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

user defined type seems lost when using union function #13286

Closed
fredgohsman opened this issue Feb 9, 2024 · 2 comments
Closed

user defined type seems lost when using union function #13286

fredgohsman opened this issue Feb 9, 2024 · 2 comments

Comments

@fredgohsman
Copy link

fredgohsman commented Feb 9, 2024

Bicep version
v0.25.3

Works in v0.24.24.
Gives error in v0.25.3

Describe the bug
Type checking of a module's param is throwing an exception when creating a variable by unioning a typed param

Error Message

WARNING: The following experimental Bicep features have been enabled: Source mapping. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.
C:\Users\fred\repos\clients\SkGlobal\BankFabricIaC\bfcv1\main.bicep(103,21) : Error BCP035: The specified "var" declaration is missing the following required properties from source declaration "databaseSettings": "administrator", "privateIpAddresses", "sku", "storageProfile", "tags", "version".

To Reproduce
Steps to reproduce the behavior:

Simplified Example

type UDF = { 
  prop1: string
  prop2: int 
}
param p UDF
var v = union(p, { prop2: 0 })

module m = './module.bicep' = {
  name: 'module'
  params: {
    udf: v
  }
}

Actual Code

@export()
type MySQLConfig = {
  administrator: Login
  privateIpAddresses: string[]
  sku: MySQLSku
  storageProfile: MySQLStorageProfile
  tags: object
  version: '5.6' | '5.7' | '8.0'
}

param databaseConfig MySQLConfig

var databaseSettings = union(databaseConfig, { administrator: { password: dbAdminPassword } })

module databaseDeploy './database.bicep' = {
  name: 'database'
  scope: resourceGroup
  params: {
    databaseConfig: databaseSettings  // line: 103 as referenced in the error message above
  }
}

Parameters file

param databaseConfig = {
  administrator: {
    username: 'AdministratorOfTheYear'
  }
  privateIpAddresses: []
  sku: {
    name: 'GP_Gen5_4'
  }
  storageProfile: {
  }
  tags: {
  }
  version: '8.0'
}

Additional context
Add any other context about the problem here.

@anthony-c-martin
Copy link
Member

I believe this should be fixed by #13272. If you want to test out the fix before it is released, see https://github.com/Azure/bicep/blob/main/docs/installing-nightly.md.

@fredgohsman
Copy link
Author

Thanks. That version does work for my scenario.

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

2 participants