Skip to content

Propagate Template Authoring errors via TemplateAuthoringException and TemplateIssueDetected status #4801

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

Open
JanKrivanek opened this issue May 31, 2022 · 0 comments
Labels
area: CLI Related to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code) Priority:3 Work that is nice to have triaged The issue was evaluated by the triage team, placed on correct area, next action defined.

Comments

@JanKrivanek
Copy link
Member

Current behavior:

Many template authoring errors end up being hidden under 'Not Found' errors - as TemplateAuthoringException is not properly thrown/handled/propagated

Example:

> dotnet new invalid01
Error: Failed to load template from "invalid01\.template.config/template.json".
Details: Newtonsoft.Json.JsonReaderException: JsonToken EndObject is not valid for closing JsonType Array. Path 'guids', line 18, position 1.
   at Newtonsoft.Json.JsonReader.ValidateEnd(JsonToken endToken)
   at Newtonsoft.Json.JsonReader.SetToken(JsonToken newToken, Object value, Boolean updateIndex)
   at Newtonsoft.Json.JsonTextReader.ParsePostValue(Boolean ignoreComments)
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options)
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader)
   at Microsoft.TemplateEngine.JExtensions.ReadJObjectFromIFile(IFile file) in C:\src\templating\src\Shared\JExtensions.cs:line 306
   at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectConfig..ctor(IEngineEnvironmentSettings settings, IGenerator generator, IFile templateFile, IFile hostConfigFile, IFile localeConfigFile, String baselineName) in C:\src\templating\src\Microsoft.TemplateEngine.Orchestrator.RunnableProjects\RunnableProjectConfig.cs:line 78
   at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.TryGetTemplateFromConfigInfo(IFileSystemInfo templateFileConfig, ITemplate& template, IFileSystemInfo localeFileConfig, IFile hostTemplateConfigFile, String baselineName) in C:\src\templating\src\Microsoft.TemplateEngine.Orchestrator.RunnableProjects\RunnableProjectGenerator.cs:line 259
Unable to locate the specified template content, the template cache may be corrupted. Try running 'dotnet Microsoft.TemplateEngine.Cli.Commands.TemplateCommandArgs --debug:reinit' to fix the issue.


For details on the exit code, refer to https://aka.ms/templating-exit-codes#103

Expected behavior:

Issues in parsing template files should be propagated via TemplateAuthoringException, that gets eventually translated to TemplateIssueDetected status and appropriate exit code.

@JanKrivanek JanKrivanek added the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Jun 7, 2022
@DamianEdwards DamianEdwards changed the title Propagate Tempalte Authoring errors via TemplateAuthoringException and TemplateIssueDetected status Propagate Template Authoring errors via TemplateAuthoringException and TemplateIssueDetected status Jun 11, 2022
@YuliiaKovalova YuliiaKovalova added Priority:3 Work that is nice to have area: refactoring The technical improvement/refactoring area: CLI Related to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code) and removed area: refactoring The technical improvement/refactoring labels May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CLI Related to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code) Priority:3 Work that is nice to have triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Projects
None yet
Development

No branches or pull requests

2 participants