bicep icon indicating copy to clipboard operation
bicep copied to clipboard

`--insert-final-newline` breaks `bicep format`

Open cecheta opened this issue 1 year ago • 0 comments

Bicep version 0.27.1

Describe the bug Running bicep format with the --insert-final-newline fails with an error:

Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Bicep.Cli.Arguments.FormatArguments..ctor(String[] args, IOContext io, IFileSystem fileSystem)
   at Bicep.Cli.Services.ArgumentParser.TryParse(String[] args, IOContext io, IFileSystem fileSystem)
   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)

To Reproduce

main.bicep:

targetScope = 'subscription'

resource   rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
  name: 'rg-name'
  location: 'uksouth'
}

Run az bicep format -f main.bicep --insert-final-newline

Additional context Running az bicep format -f main.bicep includes a final new line anyway, therefore the flag appears to be redundant at best.

cecheta avatar May 15 '24 13:05 cecheta