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

BICEP BCP079: This expression is referencing its own declaration, which is not allowed. #5313

Open
asears opened this issue Dec 2, 2021 · 5 comments

Comments

@asears
Copy link

asears commented Dec 2, 2021

Bicep version
Bicep CLI version 0.4.1008 (223b8d2)

Describe the bug
When decompiling an ARM template, I see a number of warnings in output.

BICEP BCP079: This expression is referencing its own declaration, which is not allowed.

This warning is confusing and not sure how to act on it other than deleting the description.

I would expect that Bicep understands the @description metadata tag or has some way of creating a custom attribute for this.

To Reproduce
Each line has a description.

    "parameters": {
        "workspaceName": {
            "type": "string",
            "metadata": {
                "description": "Specifies the name of the Azure Machine Learning service workspace."
            }
        },
@description('Specifies the name of the Azure Machine Learning service workspace.')
param workspaceName string

Additional context
#1665 may relate.

@ghost ghost added the Needs: Triage 🔍 label Dec 2, 2021
@alex-frankel
Copy link
Collaborator

I don't believe the code you are sharing is the source of the error. Can you share the full ARM template?

@asears
Copy link
Author

asears commented Dec 6, 2021

Can't share the full template. I'll try and create a minimal template. Will close this one until I can create a minimal repro.

@asears asears closed this as completed Dec 6, 2021
@asears asears reopened this Jan 6, 2022
@asears
Copy link
Author

asears commented Jan 6, 2022

The issue was just that "description" was used as a parameter name. Once it is identified as a parameter name, it conflicts with the built-in description attribute.

The error message wasn't so clear initially since it affected every @description('mydesc') line. I would suggest that a list of reserved words or mention that description is a reserved word and cannot be used as a parameter could be shown or provide support for both a description parameter and description attribute.

I would think name and description should be allowed parameter names and there should be no constraints as to what a parameter is called?

@alex-frankel
Copy link
Collaborator

There is only one global namespace, so identifiers can only be declared once. I agree the error message could be clearer. You can disambiguate by using the sys namespace like so:

param description string

@sys.description('foo')
param foo string

We also show you this in completions where it is relevant. Notice we don't show description in the list since it is not valid because of the description param:
image

@mav108
Copy link

mav108 commented Nov 3, 2022

I'm also having the same issue when I decompile the below ARM template....

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "azureFirewalls_afw_we_adev_play_name": {
      "defaultValue": "afw-we-adev-play",
      "type": "String"
    },
    "publicIPAddresses_pip_we_adev_afw_externalid": {
      "defaultValue": "/subscriptions/bb33c192-ceb7/resourceGroups/rg-manju-play/providers/Microsoft.Network/publicIPAddresses/pip-we-adev-afw",
      "type": "String"
    },
    "virtualNetworks_vneweadev1play_externalid": {
      "defaultValue": "/subscriptions/bb33c192-ceb7/resourceGroups/rg-manju-play/providers/Microsoft.Network/virtualNetworks/vneweadev1play",
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2022-05-01",
      "location": "westeurope",
      "name": "[parameters('azureFirewalls_afw_we_adev_play_name')]",
      "properties": {
        "additionalProperties": {},
        "applicationRuleCollections": [],
        "ipConfigurations": [
          {
            "id": "[concat(resourceId('Microsoft.Network/azureFirewalls', parameters('azureFirewalls_afw_we_adev_play_name')), '/azureFirewallIpConfigurations/pip-we-adev-afw')]",
            "name": "pip-we-adev-afw",
            "properties": {
              "publicIPAddress": {
                "id": "[parameters('publicIPAddresses_pip_we_adev_afw_externalid')]"
              },
              "subnet": {
                "id": "[concat(parameters('virtualNetworks_vneweadev1play_externalid'), '/subnets/AzureFirewallSubnet')]"
              }
            }
          }
        ],
        "natRuleCollections": [],
        "networkRuleCollections": [],
        "sku": {
          "name": "AZFW_VNet",
          "tier": "Standard"
        },
        "threatIntelMode": "Alert"
      },
      "type": "Microsoft.Network/azureFirewalls"
    }
  ],
  "variables": {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

4 participants