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

Empty bicepconfig.json breaks CLI #4242

Closed
StefanIvemo opened this issue Aug 31, 2021 · 0 comments · Fixed by #4348
Closed

Empty bicepconfig.json breaks CLI #4242

StefanIvemo opened this issue Aug 31, 2021 · 0 comments · Fixed by #4348
Assignees
Labels
bug Something isn't working top 10 committed
Milestone

Comments

@StefanIvemo
Copy link
Collaborator

Bicep version
Bicep CLI version 0.4.743 (b316af9eee)
ms-azuretools.vscode-bicep@0.4.743-gb316af9eee

Describe the bug
If you have a file named bicepconfig.json with no content the CLI will throw an unhandled exception.

Unhandled exception. System.Exception: Could not load configuration file. The input does not contain any JSON tokens. Expected the input to star   at Bicep.Core.Semantics.SemanticModel.get_LinterAnalyzer()
   at Bicep.Core.Semantics.SemanticModel.GetAnalyzerDiagnostics(ConfigHelper overrideConfig)
   at Bicep.Core.Semantics.SemanticModel.AssembleDiagnostics(ConfigHelper overrideConfig)
   at Bicep.Core.Semantics.SemanticModel.<.ctor>b__8_5()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Bicep.Core.Semantics.SemanticModel.GetAllDiagnostics(ConfigHelper overrideConfig)
   at Bicep.Core.Semantics.Compilation.<>c__DisplayClass12_0.<GetAllDiagnosticsByBicepFile>b__1(BicepFile bicepFile)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Bicep.Core.Semantics.Compilation.GetAllDiagnosticsByBicepFile(ConfigHelper overrideConfig)
   at Bicep.Cli.Services.CompilationService.LogDiagnostics(Compilation compilation)
   at Bicep.Cli.Services.CompilationService.CompileAsync(String inputPath, Boolean skipRestore)
   at Bicep.Cli.Commands.BuildCommand.RunAsync(BuildArguments args)
   at Bicep.Cli.Program.RunAsync(String[] args)
   at Bicep.Cli.Program.<Main>(String[] args)

To Reproduce

  1. Create an empty file named bicepconfig.json
  2. Create an empty bicep file named foo.bicep
  3. Run bicep build .\foo.bicep

Additional context
Should not throw an unhandled exception. The error message should let the user know the path to the bicepconfig.json file that can't be loaded.

The VS Code extension handles it better, but again since bicep will look up the tree until it finds a bicepconfig.json file it should let the user know which one to correct.

Could not load configuration file. The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.(Fatal)`
@ghost ghost added the Needs: Triage 🔍 label Aug 31, 2021
@StefanIvemo StefanIvemo changed the title Empty bicepconfig.json breaks CLI and Empty bicepconfig.json breaks CLI Aug 31, 2021
@alex-frankel alex-frankel added this to the v0.5 milestone Sep 1, 2021
@alex-frankel alex-frankel added the bug Something isn't working label Sep 1, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working top 10 committed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants