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

--insert-final-newline breaks bicep format #14099

Closed
cecheta opened this issue May 15, 2024 · 1 comment · Fixed by #14193
Closed

--insert-final-newline breaks bicep format #14099

cecheta opened this issue May 15, 2024 · 1 comment · Fixed by #14193
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cecheta
Copy link
Member

cecheta commented May 15, 2024

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.

@shenglol
Copy link
Contributor

@cecheta Thanks for reporting this!

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

That's true, but we'd like to support --insert-final-newline false to allow removing final newlines.

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
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants