Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.26k stars 753 forks source link

Error - ParameterAssignmentSymbol was not present in the dictionary #12417

Closed kevball2 closed 1 year ago

kevball2 commented 1 year ago

Bicep version run bicep --version via the Bicep CLI, az bicep version via the AZ CLI or via VS code by navigating to the extensions tab and searching for Bicep Bicep CLI version 0.23.1 (b02de2da48)

Describe the bug When declaring a user-defined-type as a parameter in the params file you are unable to reference properties from the parameter for other parameters

To Reproduce Steps to reproduce the behavior: UDT

@description('Azure environment specific configuration settings')
type AzureEnvironmentType = {
  @description('Azure  US Government specific settings')
  AzureUSGovernment: {
    @description('Azure  Gov Event Hub ResourceIds')
    eventHubName: {
      prod: 'resourceId'
      qa: 'resourceId'
      dev: 'resourceId'
    }
    @description('Azure  Gov supported regions')
    region: {
      usgovvirginia: 'ugv'
      usgovtexas: 'ugt'
    }
    @description('Azure  Gov Log Analytics ResourceIds')
    workspace: {
      prod: 'resourceId'
      qa: 'resourceId'
      dev: 'resourceId'
    }
  }
  @description('Azure  Global specific settings')
  AzureCloud: {
    @description('Azure  Global Event Hub ResourceIds')
    eventHubName: {
      prod: 'resourceId'
      qa: 'resourceId'
      dev: 'resourceId'
    }
    @description('Azure  Global supported regions')
    region: {
      eastus: 'eus'
      westus: 'wus'
    }
    @description('Azure  Global Log Analytics ResourceIds')
    workspace: {
      prod: 'resourceId'
      qa: 'resourceId'
      dev: 'resourceId'
    }
  }
}

param azureEnvironments AzureEnvironmentType

bicepparam file

using 'test.bicep'

param azureEnvironments

param region = azureEnvironments.AzureCloud.eventHubName.dev

Additional context Output error

[Error - 1:53:26 PM] Request textDocument/codeAction failed.
  Message: Internal Error - System.Collections.Generic.KeyNotFoundException: The given key 'Bicep.Core.Semantics.ParameterAssignmentSymbol' was not present in the dictionary.
   at System.Collections.Immutable.ImmutableDictionary`2.Builder.get_Item(TKey key)
   at Bicep.Core.Emit.EmitLimitationCalculator.CalculateParameterAssignments(SemanticModel model, IDiagnosticWriter diagnostics) in C:\__w\1\s\bicep\src\Bicep.Core\Emit\EmitLimitationCalculator.cs:line 569
   at Bicep.Core.Emit.EmitLimitationCalculator.Calculate(SemanticModel model) in C:\__w\1\s\bicep\src\Bicep.Core\Emit\EmitLimitationCalculator.cs:line 32
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Bicep.Core.Semantics.SemanticModel.GetSemanticDiagnostics() in C:\__w\1\s\bicep\src\Bicep.Core\Semantics\SemanticModel.cs:line 312
   at Bicep.Core.Semantics.SemanticModel.AssembleDiagnostics() in C:\__w\1\s\bicep\src\Bicep.Core\Semantics\SemanticModel.cs:line 367
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at Bicep.LanguageServer.Handlers.BicepCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in C:\__w\1\s\bicep\src\Bicep.LangServer\Handlers\BicepCodeActionHandler.cs:line 131
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
  Code: -32603 
maskati commented 1 year ago

Same error here, but so far only when combined with compileTimeImports.