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

Unhandled exception. System.ArgumentException: Unable to determine parent of specified node of type 'FunctionCallSyntax' at span '[468:520]' because it has not been indexed. #13618

Closed
slavizh opened this issue Mar 15, 2024 · 12 comments · Fixed by #13671
Assignees
Labels
bug Something isn't working
Milestone

Comments

@slavizh
Copy link
Contributor

slavizh commented Mar 15, 2024

Bicep version
Bicep CLI version 0.26.54 (5e20b29)

Describe the bug
This issue started to appear when we upgraded to 0.26.54 yesterday. We run self-hosted agents on Ubuntu 20.04. Strangely I cannot reproduce this issue on my Windows with same Bicep version but I can reproduce it on WSL Ubuntu 20.04 with bicep 0.26.54 installed. I think issue is also only related to using user defined types.

To Reproduce

main.bicep

targetScope = 'subscription'

//import * as inputSchema from './input-types.bicep'

@description('Resource Groups definition to deploy resources to.')
param resourceGroups array

param tags object = {}

param deploymentLocation string = deployment().location

param solutionVersionTag object = {}



config.bicepparam

using 'main.bicep'

param resourceGroups = [
  {
    name: 'lz-key-vault'
    location: 'West Europe'
    tags: {
      purpose: 'dev'
    ....

  }
]


Error that is produced when we try to do bicep build-params and New-AzSubscriptionDeployment

2024-03-15T06:45:03.3961356Z Unhandled exception. System.ArgumentException: Unable to determine parent of specified node of type 'FunctionCallSyntax' at span '[468:520]' because it has not been indexed.
2024-03-15T06:45:03.3961955Z    at Bicep.Core.Syntax.SyntaxHierarchy.GetParent(SyntaxBase node)
2024-03-15T06:45:03.3962256Z    at Bicep.Core.Semantics.Binder.GetParent(SyntaxBase syntax)
2024-03-15T06:45:03.3962598Z    at Bicep.Core.Syntax.ISyntaxHierarchyExtensions.EnumerateAncestorsUpwards(ISyntaxHierarchy hierarchy, SyntaxBase syntax)+MoveNext()
2024-03-15T06:45:03.3962941Z    at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable)+MoveNext()
2024-03-15T06:45:03.3963231Z    at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1, Boolean& )
2024-03-15T06:45:03.3963507Z    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 )
2024-03-15T06:45:03.3963828Z    at Bicep.Core.Syntax.ISyntaxHierarchyExtensions.GetNearestAncestor[TSyntax](ISyntaxHierarchy hierarchy, SyntaxBase syntax)
2024-03-15T06:45:03.3964163Z    at Bicep.Core.TypeSystem.DeclaredTypeManager.IsWithinTypeSyntax(SyntaxBase syntax)
2024-03-15T06:45:03.3964464Z    at Bicep.Core.TypeSystem.DeclaredTypeManager.GetTypeAssignment(SyntaxBase syntax)
2024-03-15T06:45:03.3964773Z    at Bicep.Core.TypeSystem.DeclaredTypeManager.<GetDeclaredTypeAssignment>b__8_0(SyntaxBase key)
2024-03-15T06:45:03.3965368Z    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2)
2024-03-15T06:45:03.3965674Z    at Bicep.Core.TypeSystem.DeclaredTypeManager.GetDeclaredTypeAssignment(SyntaxBase syntax)
2024-03-15T06:45:03.3965981Z    at Bicep.Core.TypeSystem.DeclaredTypeManager.GetDeclaredType(SyntaxBase syntax)
2024-03-15T06:45:03.3966269Z    at Bicep.Core.TypeSystem.TypeManager.GetDeclaredType(SyntaxBase syntax)
2024-03-15T06:45:03.3966593Z    at Bicep.Core.Semantics.SymbolHelper.TryGetSymbolInfo(IBinder binder, Func`2 getDeclaredTypeFunc, SyntaxBase syntax)
2024-03-15T06:45:03.3966918Z    at Bicep.Core.Semantics.SemanticModel.GetSymbolInfo(SyntaxBase syntax)
2024-03-15T06:45:03.3967234Z    at Bicep.Core.Intermediate.ExpressionBuilder.ConvertPropertyAccess(PropertyAccessSyntax propertyAccess)
2024-03-15T06:45:03.3967560Z    at Bicep.Core.Intermediate.ExpressionBuilder.ConvertWithoutLowering(SyntaxBase syntax)
2024-03-15T06:45:03.3967859Z    at Bicep.Core.Intermediate.ExpressionBuilder.Convert(SyntaxBase syntax)
2024-03-15T06:45:03.3968252Z    at Bicep.Core.Emit.ExpressionConverter.ConvertToIntermediateExpression(SyntaxBase syntax)
2024-03-15T06:45:03.3968562Z    at Bicep.Core.Emit.ExpressionConverter.ConvertExpression(SyntaxBase syntax)
2024-03-15T06:45:03.3968962Z    at Bicep.Core.Emit.ScopeHelper.FormatFullyQualifiedResourceId(EmitterContext context, ExpressionConverter converter, ScopeData scopeData, String fullyQualifiedType, IEnumerable`1 nameSegments)
2024-03-15T06:45:03.3969379Z    at Bicep.Core.Emit.ExpressionConverter.GetFullyQualifiedResourceId(ResourceMetadata resource)
2024-03-15T06:45:03.3969754Z    at Bicep.Core.Emit.ExpressionConverter.ConvertResourcePropertyAccess(ResourceReferenceExpression reference, PropertyAccessExpression expression)
2024-03-15T06:45:03.3970124Z    at Bicep.Core.Emit.ExpressionConverter.ConvertBaseExpression(AccessExpression expression)
2024-03-15T06:45:03.3970503Z    at Bicep.Core.Emit.ExpressionConverter.ProcessAccessExpression(AccessExpression expression)
2024-03-15T06:45:03.3970865Z    at Bicep.Core.Emit.ExpressionConverter.ConvertAccessExpression(AccessExpression expression, IEnumerable`1 additionalProperties)
2024-03-15T06:45:03.3971215Z    at Bicep.Core.Emit.ExpressionConverter.ConvertExpression(Expression expression)
2024-03-15T06:45:03.3971515Z    at Bicep.Core.Emit.ExpressionEmitter.EmitLanguageExpression(Expression expression)
2024-03-15T06:45:03.3971809Z    at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
2024-03-15T06:45:03.3972099Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
2024-03-15T06:45:03.3972440Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.3972855Z    at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
2024-03-15T06:45:03.3973234Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
2024-03-15T06:45:03.3973548Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
2024-03-15T06:45:03.3973850Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
2024-03-15T06:45:03.3974145Z    at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
2024-03-15T06:45:03.3974435Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
2024-03-15T06:45:03.3974781Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.3975192Z    at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
2024-03-15T06:45:03.3975568Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
2024-03-15T06:45:03.3975972Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
2024-03-15T06:45:03.3976277Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass17_0.<EmitCopyObject>b__1()
2024-03-15T06:45:03.3976616Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.3977033Z    at Bicep.Core.Emit.ExpressionEmitter.EmitCopyObject(String name, Expression forExpression, Expression input, String copyIndexOverride, Nullable`1 batchSize)
2024-03-15T06:45:03.4020787Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass18_0.<EmitObjectProperties>b__1()
2024-03-15T06:45:03.4021374Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4021827Z    at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
2024-03-15T06:45:03.4022475Z    at Bicep.Core.Emit.ExpressionEmitter.EmitCopyProperty(Action valueFunc)
2024-03-15T06:45:03.4022776Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
2024-03-15T06:45:03.4023098Z    at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
2024-03-15T06:45:03.4023394Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
2024-03-15T06:45:03.4023739Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4024159Z    at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
2024-03-15T06:45:03.4024533Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
2024-03-15T06:45:03.4024849Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
2024-03-15T06:45:03.4025161Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
2024-03-15T06:45:03.4025459Z    at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
2024-03-15T06:45:03.4025756Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
2024-03-15T06:45:03.4026121Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4026539Z    at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
2024-03-15T06:45:03.4027061Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
2024-03-15T06:45:03.4027368Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
2024-03-15T06:45:03.4027675Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
2024-03-15T06:45:03.4027978Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass62_0.<EmitResource>b__0()
2024-03-15T06:45:03.4028318Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.4028677Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4029025Z    at Bicep.Core.Emit.TemplateWriter.EmitResource(ExpressionEmitter emitter, DeclaredResourceExpression resource)
2024-03-15T06:45:03.4029350Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_0.<EmitResources>b__0()
2024-03-15T06:45:03.4029688Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteArrayWithPosition(IPositionable sourcePosition, Action itemsFunc)
2024-03-15T06:45:03.4030035Z    at Bicep.Core.Emit.ExpressionEmitter.EmitArray(Action writeItemsFunc, IPositionable position)
2024-03-15T06:45:03.4030468Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass33_0.<EmitArrayProperty>b__0()
2024-03-15T06:45:03.4030828Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4031204Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
2024-03-15T06:45:03.4031576Z    at Bicep.Core.Emit.ExpressionEmitter.EmitArrayProperty(String propertyName, Action writeItemsFunc, IPositionable position)
2024-03-15T06:45:03.4031997Z    at Bicep.Core.Emit.TemplateWriter.EmitResources(PositionTrackingJsonTextWriter jsonWriter, ExpressionEmitter emitter, ImmutableArray`1 resources, ImmutableArray`1 modules)
2024-03-15T06:45:03.4032401Z    at Bicep.Core.Emit.TemplateWriter.GenerateTemplateWithoutHash(PositionTrackingJsonTextWriter jsonWriter)
2024-03-15T06:45:03.4032718Z    at Bicep.Core.Emit.TemplateWriter.Write(SourceAwareJsonTextWriter writer)
2024-03-15T06:45:03.4033013Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__2()
2024-03-15T06:45:03.4033418Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.4033780Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4034104Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass32_0.<EmitObjectProperty>b__0()
2024-03-15T06:45:03.4034457Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4034834Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
2024-03-15T06:45:03.4035208Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperty(String propertyName, Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4035545Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__0()
2024-03-15T06:45:03.4035886Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.4036241Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4036622Z    at Bicep.Core.Emit.TemplateWriter.EmitModule(PositionTrackingJsonTextWriter jsonWriter, DeclaredModuleExpression module, ExpressionEmitter emitter)
2024-03-15T06:45:03.4036981Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_0.<EmitResources>b__0()
2024-03-15T06:45:03.4037313Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteArrayWithPosition(IPositionable sourcePosition, Action itemsFunc)
2024-03-15T06:45:03.4037662Z    at Bicep.Core.Emit.ExpressionEmitter.EmitArray(Action writeItemsFunc, IPositionable position)
2024-03-15T06:45:03.4037977Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass33_0.<EmitArrayProperty>b__0()
2024-03-15T06:45:03.4038332Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4038712Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
2024-03-15T06:45:03.4039084Z    at Bicep.Core.Emit.ExpressionEmitter.EmitArrayProperty(String propertyName, Action writeItemsFunc, IPositionable position)
2024-03-15T06:45:03.4039625Z    at Bicep.Core.Emit.TemplateWriter.EmitResources(PositionTrackingJsonTextWriter jsonWriter, ExpressionEmitter emitter, ImmutableArray`1 resources, ImmutableArray`1 modules)
2024-03-15T06:45:03.4040027Z    at Bicep.Core.Emit.TemplateWriter.GenerateTemplateWithoutHash(PositionTrackingJsonTextWriter jsonWriter)
2024-03-15T06:45:03.4040347Z    at Bicep.Core.Emit.TemplateWriter.Write(SourceAwareJsonTextWriter writer)
2024-03-15T06:45:03.4040637Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__2()
2024-03-15T06:45:03.4041042Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.4041406Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4041728Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass32_0.<EmitObjectProperty>b__0()
2024-03-15T06:45:03.4042081Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4042459Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
2024-03-15T06:45:03.4042837Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperty(String propertyName, Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4043174Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__0()
2024-03-15T06:45:03.4043515Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.4043937Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4044318Z    at Bicep.Core.Emit.TemplateWriter.EmitModule(PositionTrackingJsonTextWriter jsonWriter, DeclaredModuleExpression module, ExpressionEmitter emitter)
2024-03-15T06:45:03.4044673Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_2.<EmitResources>b__3()
2024-03-15T06:45:03.4045020Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4045395Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
2024-03-15T06:45:03.4045725Z    at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_0.<EmitResources>b__1()
2024-03-15T06:45:03.4046071Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
2024-03-15T06:45:03.4046436Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4046757Z    at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass32_0.<EmitObjectProperty>b__0()
2024-03-15T06:45:03.4047109Z    at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
2024-03-15T06:45:03.4047484Z    at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
2024-03-15T06:45:03.4047857Z    at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperty(String propertyName, Action writePropertiesFunc, IPositionable position)
2024-03-15T06:45:03.4048281Z    at Bicep.Core.Emit.TemplateWriter.EmitResources(PositionTrackingJsonTextWriter jsonWriter, ExpressionEmitter emitter, ImmutableArray`1 resources, ImmutableArray`1 modules)
2024-03-15T06:45:03.4048688Z    at Bicep.Core.Emit.TemplateWriter.GenerateTemplateWithoutHash(PositionTrackingJsonTextWriter jsonWriter)
2024-03-15T06:45:03.4049005Z    at Bicep.Core.Emit.TemplateWriter.Write(SourceAwareJsonTextWriter writer)
2024-03-15T06:45:03.4049290Z    at Bicep.Core.Emit.TemplateEmitter.<>c__DisplayClass8_0.<Emit>b__0()
2024-03-15T06:45:03.4049560Z    at Bicep.Core.Emit.TemplateEmitter.EmitOrFail(Func`1 write)
2024-03-15T06:45:03.4049827Z    at Bicep.Core.Emit.TemplateEmitter.Emit(TextWriter textWriter)
2024-03-15T06:45:03.4050104Z    at Bicep.Core.Emit.CompilationEmitter.Template(SemanticModel model)
2024-03-15T06:45:03.4050369Z    at Bicep.Core.Emit.CompilationEmitter.Parameters()
2024-03-15T06:45:03.4050641Z    at Bicep.Cli.Services.OutputWriter.ParametersToStdout(Compilation compilation)
2024-03-15T06:45:03.4050938Z    at Bicep.Cli.Commands.BuildParamsCommand.RunAsync(BuildParamsArguments args)
2024-03-15T06:45:03.4051297Z    at Bicep.Cli.Program.RunAsync(String[] args, CancellationToken cancellationToken)
2024-03-15T06:45:03.4051588Z    at Bicep.Cli.Program.<>c__DisplayClass3_0.<<Main>b__0>d.MoveNext()
2024-03-15T06:45:03.4052079Z --- End of stack trace from previous location ---
2024-03-15T06:45:03.4052334Z    at Bicep.Cli.Program.RunWithCancellationAsync(Func`2 runFunc)
2024-03-15T06:45:03.4052578Z    at Bicep.Cli.Program.Main(String[] args)
2024-03-15T06:45:03.4052803Z    at Bicep.Cli.Program.<Main>(String[] args)
2024-03-15T06:45:03.5998350Z 
2024-03-15T06:45:03.5999060Z 

Additionally I get another PowerShell error when I run with new-azsubscriptiondeployment:

     | Cannot retrieve the dynamic parameters for the cmdlet.
     | /azp/agent/_work/32/s/modules/key-vault.bicep(117,87) : Warning
     | use-recent-api-versions: Use more recent API version for
     | 'Microsoft.Insights/diagnosticSettings'. '2021-05-01-preview' is 1049
     | days old, should be no more than 730 days old, or the most recent.
     | Acceptable versions: 2016-09-01
     | [https://aka.ms/bicep/linter/use-recent-api-versions]
     | /azp/agent/_work/32/s/modules/key-vault.bicep(159,74) : Warning
     | use-recent-api-versions: Use more recent API version for
     | 'Microsoft.Insights/diagnosticSettings'. '2021-05-01-preview' is 1049
     | days old, should be no more than 730 days old, or the most recent.
     | Acceptable versions: 2016-09-01
     | [https://aka.ms/bicep/linter/use-recent-api-versions]
     | /azp/agent/_work/32/s/modules/key-vault.bicep(201,82) : Warning
     | use-recent-api-versions: Use more recent API version for
     | 'Microsoft.Insights/diagnosticSettings'. '2021-05-01-preview' is 1049
     | days old, should be no more than 730 days old, or the most recent.
     | Acceptable versions: 2016-09-01
     | [https://aka.ms/bicep/linter/use-recent-api-versions]
     | /azp/agent/_work/32/s/acceptance/lz-key-vault/config.bicepparam(3,24) :
     .....

As you can see besides the bicep error I also get: Cannot retrieve the dynamic parameters for the cmdlet.

I do not know if the issues are two or one.

The above reproduction is partial template code without user defined types. If needed I can provide the full template with user defined types in private.

Additional context
Add any other context about the problem here.

@anthony-c-martin
Copy link
Member

Unfortunately it looks like we don't log enough information to identify which module the problem is occurring in. What I can see from the message is that it's occurring in a grandchild module - e.g. with a structure like:

bicepparam
-> module
  -> module
     -> module <- the problem is in this file, between characters 468 and 520

This may not help narrow it down too much, depending on how complex your deployment is. The easiest option I've found to figure out the character position (which doesn't include line numbers) is to select from the start of the file, and look at this in VSCode:
image

If that doesn't help figure out where the problem is, I can add some logging and give you a nightly build to get more detail.

@slavizh
Copy link
Contributor Author

slavizh commented Mar 15, 2024

@anthony-c-martin I am not seeing any errors. As in order to reproduce this outside of our environment (as I have already reverted to 0.25) I am using WSL with Ubuntu. I have tried running VSC in WSL mode but I am not getting any errors there. Due to that may be nightly bicep file would be better to try on so I can execute the command instead of opening vsc.

@slavizh
Copy link
Contributor Author

slavizh commented Mar 18, 2024

@anthony-c-martin may be I have forgot to mention that the issue does not happen only on one template. It happens on multiple ones. I think all that have user defined schema. I have not tested every one of them but I got reported for at least 3 of them. The one mentioned is just one example. Let me know where I can download this debug bicep cli when ready and I will test to see what it shows.

@anthony-c-martin
Copy link
Member

anthony-c-martin commented Mar 18, 2024

I've submitted a PR which will trigger a nightly build: #13655. This will add more identifying information to the error to allow us to locate the problematic file + location.

If you want to try it in a build pipeline, you should be able to use the nightly install script. Here's a powershell example:

# <path_to_binary> here should be replaced with the path to where you want bicep.exe to be installed (e.g. C:\foo\bar would result in C:\foo\bar\bicep.exe)
iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 8329672150 -BinaryPath <path_to_binary>" 

@slavizh
Copy link
Contributor Author

slavizh commented Mar 19, 2024

@anthony-c-martin I am having trouble doing this. First I cannot do it on Windows as the problem is visible only on Ubuntu. I have tried:

bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh)  --run-id 8329672150 --binary-path /home/stan
mv: cannot stat '/tmp/tmp.nkOoEz9Xym/bicep': No such file or directory

but got error as you can see.

@anthony-c-martin
Copy link
Member

Strange... does the following work?

gh run download -R Azure/bicep 8329672150 -n "bicep-release-linux-x64" --dir /home/stan
chmod +x /home/stan/bicep
/home/stan/bicep --version

@slavizh
Copy link
Contributor Author

slavizh commented Mar 19, 2024

@anthony-c-martin yes. thank you! I think we have the line number. Below is the error generated by the template:

Unhandled exception. System.ArgumentException: Unable to determine parent of specified node of type 'FunctionCallSyntax' at span '[483:535]' because it has not been indexed. Source file: file:///home/stan/modules/key-vault.bicep, line: 15, char: 23. Node contents: union(defaultVirtualNetworkRule, keyVault.network.virtualNetworkRules[i]).
   at Bicep.Core.Syntax.SyntaxHierarchy.GetParent(SyntaxBase node)
   at Bicep.Core.Semantics.Binder.GetParent(SyntaxBase syntax)
   at Bicep.Core.Syntax.ISyntaxHierarchyExtensions.EnumerateAncestorsUpwards(ISyntaxHierarchy hierarchy, SyntaxBase syntax)+MoveNext()
   at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable)+MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1, Boolean& )
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 )
   at Bicep.Core.Syntax.ISyntaxHierarchyExtensions.GetNearestAncestor[TSyntax](ISyntaxHierarchy hierarchy, SyntaxBase syntax)
   at Bicep.Core.TypeSystem.DeclaredTypeManager.IsWithinTypeSyntax(SyntaxBase syntax)
   at Bicep.Core.TypeSystem.DeclaredTypeManager.GetTypeAssignment(SyntaxBase syntax)
   at Bicep.Core.TypeSystem.DeclaredTypeManager.<GetDeclaredTypeAssignment>b__8_0(SyntaxBase key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2)
   at Bicep.Core.TypeSystem.DeclaredTypeManager.GetDeclaredTypeAssignment(SyntaxBase syntax)
   at Bicep.Core.TypeSystem.DeclaredTypeManager.GetDeclaredType(SyntaxBase syntax)
   at Bicep.Core.TypeSystem.TypeManager.GetDeclaredType(SyntaxBase syntax)
   at Bicep.Core.Semantics.SymbolHelper.TryGetSymbolInfo(IBinder binder, Func`2 getDeclaredTypeFunc, SyntaxBase syntax)
   at Bicep.Core.Semantics.SemanticModel.GetSymbolInfo(SyntaxBase syntax)
   at Bicep.Core.Intermediate.ExpressionBuilder.ConvertPropertyAccess(PropertyAccessSyntax propertyAccess)
   at Bicep.Core.Intermediate.ExpressionBuilder.ConvertWithoutLowering(SyntaxBase syntax)
   at Bicep.Core.Intermediate.ExpressionBuilder.Convert(SyntaxBase syntax)
   at Bicep.Core.Emit.ExpressionConverter.ConvertToIntermediateExpression(SyntaxBase syntax)
   at Bicep.Core.Emit.ExpressionConverter.ConvertExpression(SyntaxBase syntax)
   at Bicep.Core.Emit.ScopeHelper.FormatFullyQualifiedResourceId(EmitterContext context, ExpressionConverter converter, ScopeData scopeData, String fullyQualifiedType, IEnumerable`1 nameSegments)
   at Bicep.Core.Emit.ExpressionConverter.GetFullyQualifiedResourceId(ResourceMetadata resource)
   at Bicep.Core.Emit.ExpressionConverter.ConvertResourcePropertyAccess(ResourceReferenceExpression reference, PropertyAccessExpression expression)
   at Bicep.Core.Emit.ExpressionConverter.ConvertBaseExpression(AccessExpression expression)
   at Bicep.Core.Emit.ExpressionConverter.ProcessAccessExpression(AccessExpression expression)
   at Bicep.Core.Emit.ExpressionConverter.ConvertAccessExpression(AccessExpression expression, IEnumerable`1 additionalProperties)
   at Bicep.Core.Emit.ExpressionConverter.ConvertExpression(Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitLanguageExpression(Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
   at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass17_0.<EmitCopyObject>b__1()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitCopyObject(String name, Expression forExpression, Expression input, String copyIndexOverride, Nullable`1 batchSize)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass18_0.<EmitObjectProperties>b__1()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
   at Bicep.Core.Emit.ExpressionEmitter.EmitCopyProperty(Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
   at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
   at Bicep.Core.Emit.ExpressionEmitter.EmitExpression(Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass22_0.<EmitProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitPropertyInternal(LanguageExpression expressionKey, Action valueFunc, IPositionable location, Boolean skipCopyCheck)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(Expression name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String name, Expression expression)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperties(ObjectExpression object)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass62_0.<EmitResource>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.EmitResource(ExpressionEmitter emitter, DeclaredResourceExpression resource)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_0.<EmitResources>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteArrayWithPosition(IPositionable sourcePosition, Action itemsFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitArray(Action writeItemsFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass33_0.<EmitArrayProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.EmitArrayProperty(String propertyName, Action writeItemsFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.EmitResources(PositionTrackingJsonTextWriter jsonWriter, ExpressionEmitter emitter, ImmutableArray`1 resources, ImmutableArray`1 modules)
   at Bicep.Core.Emit.TemplateWriter.GenerateTemplateWithoutHash(PositionTrackingJsonTextWriter jsonWriter)
   at Bicep.Core.Emit.TemplateWriter.Write(SourceAwareJsonTextWriter writer)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__2()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass32_0.<EmitObjectProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperty(String propertyName, Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.EmitModule(PositionTrackingJsonTextWriter jsonWriter, DeclaredModuleExpression module, ExpressionEmitter emitter)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_0.<EmitResources>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteArrayWithPosition(IPositionable sourcePosition, Action itemsFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitArray(Action writeItemsFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass33_0.<EmitArrayProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.EmitArrayProperty(String propertyName, Action writeItemsFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.EmitResources(PositionTrackingJsonTextWriter jsonWriter, ExpressionEmitter emitter, ImmutableArray`1 resources, ImmutableArray`1 modules)
   at Bicep.Core.Emit.TemplateWriter.GenerateTemplateWithoutHash(PositionTrackingJsonTextWriter jsonWriter)
   at Bicep.Core.Emit.TemplateWriter.Write(SourceAwareJsonTextWriter writer)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__2()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass32_0.<EmitObjectProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperty(String propertyName, Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass65_0.<EmitModule>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.EmitModule(PositionTrackingJsonTextWriter jsonWriter, DeclaredModuleExpression module, ExpressionEmitter emitter)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_2.<EmitResources>b__3()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.<>c__DisplayClass61_0.<EmitResources>b__1()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WriteObjectWithPosition(IPositionable sourcePosition, Action propertiesFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObject(Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.<>c__DisplayClass32_0.<EmitObjectProperty>b__0()
   at Bicep.Core.Emit.PositionTrackingJsonTextWriter.WritePropertyWithPosition(IPositionable keyPosition, String name, Action valueFunc)
   at Bicep.Core.Emit.ExpressionEmitter.EmitProperty(String propertyName, Action writeValueFunc, IPositionable position)
   at Bicep.Core.Emit.ExpressionEmitter.EmitObjectProperty(String propertyName, Action writePropertiesFunc, IPositionable position)
   at Bicep.Core.Emit.TemplateWriter.EmitResources(PositionTrackingJsonTextWriter jsonWriter, ExpressionEmitter emitter, ImmutableArray`1 resources, ImmutableArray`1 modules)
   at Bicep.Core.Emit.TemplateWriter.GenerateTemplateWithoutHash(PositionTrackingJsonTextWriter jsonWriter)
   at Bicep.Core.Emit.TemplateWriter.Write(SourceAwareJsonTextWriter writer)
   at Bicep.Core.Emit.TemplateEmitter.<>c__DisplayClass8_0.<Emit>b__0()
   at Bicep.Core.Emit.TemplateEmitter.EmitOrFail(Func`1 write)
   at Bicep.Core.Emit.TemplateEmitter.Emit(TextWriter textWriter)
   at Bicep.Core.Emit.CompilationEmitter.Template(SemanticModel model)
   at Bicep.Core.Emit.CompilationEmitter.Parameters()
   at Bicep.Cli.Services.OutputWriter.ParametersToStdout(Compilation compilation)
   at Bicep.Cli.Commands.BuildParamsCommand.RunAsync(BuildParamsArguments args)
   at Bicep.Cli.Program.RunAsync(String[] args, CancellationToken cancellationToken)
   at Bicep.Cli.Program.<>c__DisplayClass3_0.<<Main>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Bicep.Cli.Program.RunWithCancellationAsync(Func`2 runFunc)
   at Bicep.Cli.Program.Main(String[] args)
   at Bicep.Cli.Program.<Main>(String[] args)
Aborted

@slavizh
Copy link
Contributor Author

slavizh commented Mar 19, 2024

line 14-22. Perfectly normal syntax that we use on many templates.

resource virtualNetworks 'Microsoft.Network/virtualNetworks@2023-09-01' existing = [for virtualNetworkRule in keyVault.network.virtualNetworkRules: {
  name: virtualNetworkRule.virtualNetwork.name
  scope: resourceGroup(union(defaultVirtualNetworkRule, virtualNetworkRule).virtualNetwork.subscriptionId, virtualNetworkRule.virtualNetwork.resourceGroup)
}]

resource subnets 'Microsoft.Network/virtualNetworks/subnets@2023-09-01' existing = [for (virtualNetworkRule, i) in keyVault.network.virtualNetworkRules: {
  name: virtualNetworkRule.virtualNetwork.subnetName
  parent: virtualNetworks[i]
}]

@anthony-c-martin
Copy link
Member

I believe this is a regression in #13546 with the introduction of this check. @jeskew would you mind taking a look?

It would also be good to understand where the nondeterminism (different results on different runs) is coming from - elsewhere we've tried to keep the compilation logic deterministic.

@slavizh
Copy link
Contributor Author

slavizh commented Mar 19, 2024

@anthony-c-martin lol. If that is the culprit it is something that I have requested :D. Yeah, it is also strange that it does not errors out on Windows but only on Linux.

@jeskew jeskew added the bug Something isn't working label Mar 19, 2024
@jeskew jeskew self-assigned this Mar 19, 2024
@jeskew jeskew added this to the v0.27 milestone Mar 19, 2024
@HanMan858
Copy link

HanMan858 commented Mar 20, 2024

I am also facing the same issue in Azur pipelines with Ubuntu agent.
It was working till morning and started failing now.

I can see only build agent version image got changed as below

Succeeded agent Current image version: '20240310.1.0'
Failed agent Current image version: '20240317.1.0'

Please let us know if anybody have any idea on this.

@anthony-c-martin
Copy link
Member

For a temporary workaround, I would recommend manually reverting back to an older version of Bicep. If you're using Azure CLI, you'll need to run the following before running your AzCLI commands to submit the deployment:

az bicep install --version v0.25.53

@jeskew jeskew modified the milestones: v0.27, v0.26 Mar 27, 2024
jeskew added a commit that referenced this issue Mar 27, 2024
…13671)

Resolves #13618

In order to make type determinations, the `DeclaredTypeManager` needs to
know whether it is within type syntax or expression syntax. This
distinction is meaningful for property access (e.g., `<array type>[*]`
is legal within type syntax but not within expression syntax, whereas
`<array value>[?0]` is legal within expression syntax but not within
type syntax), variable access (variables within type syntax can refer to
other types but not values, and variables within expression syntax can
refer to values but not types), nullability control syntax, and literal
value syntax.

Prior to Bicep 0.26, the type manager was relying on internal state that
assumed the AST would be visited in order. This resulted in unstable
type assignments if the type of type syntax was requested out of order.
In Bicep 0.26.54, this was replaced with a deterministic check that used
the model's syntax hierarchy to determine whether a given syntax node
was a descendant of the type declaration of an `output` or `parameter`
statement or the assigned value of a `type` statement (indicating type
syntax) or not (indicating expression syntax). However, querying the
syntax hierarchy can throw an exception if a node was not part of the
original model (e.g., if it was created by a `SyntaxRewriteVisitor`).

This PR moves the responsibility for making this distinction to the
parser. The parser is already tracking whether it is within type syntax
or expression syntax, as the grammar for each syntax class is distinct.
This PR introduces some new descendent classes of `TypeSyntax` that are
minimally changed copies of descendent classes of `ExpressionSyntax`:
`VariableAccessSyntax` is a descendent of `ExpressionSyntax`, and
`TypeVariableAccessSyntax` is a descendent of `TypeSyntax`, but the two
classes are otherwise identical. This means that the compiler can
determine whether an arbitrary syntax node was encountered in type
syntax or expression syntax based solely on the C# type of the syntax
node rather than having to rely on the syntax hierarchy or order of
operations.

About 50% of the line count for this PR comes from baseline changes.
These are all to the `main.syntax.bicep` artifacts and consist of the
class name for specific nodes being changed (e.g.,
`VariableAccessSyntax` -> `TypeVariableAccessSyntax`, `StringSyntax` ->
`StringTypeLiteralSyntax`, etc.).

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/13671)
StephenWeatherford pushed a commit that referenced this issue Apr 1, 2024
…13671)

Resolves #13618

In order to make type determinations, the `DeclaredTypeManager` needs to
know whether it is within type syntax or expression syntax. This
distinction is meaningful for property access (e.g., `<array type>[*]`
is legal within type syntax but not within expression syntax, whereas
`<array value>[?0]` is legal within expression syntax but not within
type syntax), variable access (variables within type syntax can refer to
other types but not values, and variables within expression syntax can
refer to values but not types), nullability control syntax, and literal
value syntax.

Prior to Bicep 0.26, the type manager was relying on internal state that
assumed the AST would be visited in order. This resulted in unstable
type assignments if the type of type syntax was requested out of order.
In Bicep 0.26.54, this was replaced with a deterministic check that used
the model's syntax hierarchy to determine whether a given syntax node
was a descendant of the type declaration of an `output` or `parameter`
statement or the assigned value of a `type` statement (indicating type
syntax) or not (indicating expression syntax). However, querying the
syntax hierarchy can throw an exception if a node was not part of the
original model (e.g., if it was created by a `SyntaxRewriteVisitor`).

This PR moves the responsibility for making this distinction to the
parser. The parser is already tracking whether it is within type syntax
or expression syntax, as the grammar for each syntax class is distinct.
This PR introduces some new descendent classes of `TypeSyntax` that are
minimally changed copies of descendent classes of `ExpressionSyntax`:
`VariableAccessSyntax` is a descendent of `ExpressionSyntax`, and
`TypeVariableAccessSyntax` is a descendent of `TypeSyntax`, but the two
classes are otherwise identical. This means that the compiler can
determine whether an arbitrary syntax node was encountered in type
syntax or expression syntax based solely on the C# type of the syntax
node rather than having to rely on the syntax hierarchy or order of
operations.

About 50% of the line count for this PR comes from baseline changes.
These are all to the `main.syntax.bicep` artifacts and consist of the
class name for specific nodes being changed (e.g.,
`VariableAccessSyntax` -> `TypeVariableAccessSyntax`, `StringSyntax` ->
`StringTypeLiteralSyntax`, etc.).

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/13671)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants