You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following when running this tool across many templates, using the parameters TemplateAnalyzer analyze-template infra/main.bicep --report-format Console
Error: An exception occurred while analyzing template /Users/anthonyshaw/projects/APICenter-Analyzer/infra/main.bicep
Exception details:
Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzerException: Error while evaluating rules.
---> Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzerException: Error while processing template.
---> Newtonsoft.Json.JsonSerializationException: Deserialized JSON type 'Newtonsoft.Json.Linq.JValue' is not compatible with expected type 'Newtonsoft.Json.Linq.JObject'. Path 'parameters.applicationInsightsName', line 1, position 3165.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateJToken(JsonReader reader, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject[T]()
at Microsoft.Azure.Templates.Analyzer.TemplateProcessor.ArmTemplateProcessor.PopulateParameters(String parameters)
at Microsoft.Azure.Templates.Analyzer.TemplateProcessor.ArmTemplateProcessor.ProcessTemplate(String parameters, String metadata)
at Microsoft.Azure.Templates.Analyzer.TemplateProcessor.ArmTemplateProcessor.ProcessTemplate(String parameters)
at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeAllIncludedTemplates(String populatedTemplate, String parameters, String templateFilePath, TemplateContext parentContext, String pathPrefix)
--- End of inner exception stack trace ---
at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeAllIncludedTemplates(String populatedTemplate, String parameters, String templateFilePath, TemplateContext parentContext, String pathPrefix)
at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeAllIncludedTemplates(String populatedTemplate, String parameters, String templateFilePath, TemplateContext parentContext, String pathPrefix)
--- End of inner exception stack trace ---
at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeAllIncludedTemplates(String populatedTemplate, String parameters, String templateFilePath, TemplateContext parentContext, String pathPrefix)
at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeTemplate(String template, String templateFilePath, String parameters)
at Microsoft.Azure.Templates.Analyzer.Cli.CommandLineParser.AnalyzeTemplate(TemplateAndParams templateAndParameters)
Execution summary:
Summary of the warnings:
1 instance of: An exception occurred while evaluating the properties of the resource named functionapp
1 instance of: An exception occurred while evaluating the properties of the resource named apicenteraccess
1 instance of: An exception occurred while evaluating the properties of the resource named apicenteraccessexist
1 instance of: The parsing of the template output named AZURE_FUNCTION_NAME failed
1 instance of: The parsing of the template output named primaryEndpoints failed
Summary of the errors:
1 instance of: An exception occurred while analyzing template /Users/anthonyshaw/projects/APICenter-Analyzer/infra/main.bicep
5 Warnings
1 Error
It stops analysing the template at that stage.
I put a breakpoint in Visual Studio with this project in debug mode to better understand it, the parameters it was evaluating look like this:
Hi @tonybaloney. I'm a bit confused at the example parameters you've provided that produce the error. That JSON does not match the schema for parameters files. Can you explain your scenario a bit more?
Giving the stack trace shown above. The parameter file in this repo is valid.
The JSON I gave in the issue was captured by putting a breakpoint in this project and catching the exception then looking at the JSON it was trying to deserialize.
Thanks @tonybaloney for the additional clarification. Properly resolving this will require a bit more investigation into how the parameters end up in this format during execution, so we can fully understand how to process it correctly. Since the scanned template includes Bicep transformations and potentially multiple modules, it requires more careful consideration.
Describe the bug
I get the following when running this tool across many templates, using the parameters
TemplateAnalyzer analyze-template infra/main.bicep --report-format Console
It stops analysing the template at that stage.
I put a breakpoint in Visual Studio with this project in debug mode to better understand it, the parameters it was evaluating look like this:
It crashes because this line https://github.com/Azure/template-analyzer/blob/main/src/Analyzer.TemplateProcessor/ArmTemplateProcessor.cs#L549 assumes that the parameter is an object, but the
name
parameter is a string with an expression inside it.Expected behavior
see detail
Reproduction Steps
see detail
Environment
No response
The text was updated successfully, but these errors were encountered: