runner.server icon indicating copy to clipboard operation
runner.server copied to clipboard

azpexpand command should not show StackTrace when there are template errors

Open bryanbcook opened this issue 2 years ago • 1 comments

Exceptions should not propagate to end-users through public interfaces unless they are the result of uncaught issues in the application logic.

Expected:

c:\> gharun -W /pipelines/pipeline1.yml
The template is not valid.
(self)/pipeline1.yml: (Line: 28, Col: 1, Idx: 1024): While parsing a block mapping, did not find expected key.
c:\> $LASTEXITCODE
1

Actual:

c:\> gharun -W /pipelines/pipeline1.yml
<...log-contents...>
(self)/pipelines/pipeline1.yml: (Line: 28, Col: 1, Idx: 1042) - (Line: 28, Col: 6, Idx: 1047): While parsing a block mapping, did not find expected key.
Exception: The template is not valid. (self)/pipelines/pipeline1.yml: (Line: 28, Col: 1, Idx: 1042) - (Line: 28, Col: 6, Idx: 1047): While parsing a block mapping, did not find expected key.,    at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check() in /home/runner/work/runner.server/runner.server/src/Sdk/DTObjectTemplating/ObjectTemplating/TemplateValidationErrors.cs:line 88
   at AzureDevops.ReadTemplate(Context context, String filenameAndRef, Dictionary`2 cparameters, String schemaName) in /home/runner/work/runner.server/runner.server/src/Sdk/AzurePipelines/AzureDevops.cs:line 494
   at Runner.Client.Program.AzurePipelinesExpander.ExpandCurrentPipeline(Parameters handle, String currentFileName) in /home/runner/work/runner.server/runner.server/src/Runner.Client/Program.cs:line 828
   at Runner.Client.Program.<>c__DisplayClass29_2.<<Main>b__17>d.MoveNext() in /home/runner/work/runner.server/runner.server/src/Runner.Client/Program.cs:line 1710
c:\> $LASTEXITCODE
1

bryanbcook avatar Nov 30 '23 19:11 bryanbcook

  1. Hide Trace messages (to suppress the duplicated error) > move them to log file like in 277
  2. Print Exception.Message instead of Exception.toString() so it doesn't include the exception name / stacktrace.

The template is not valid. wouldn't be followed by a newline, but otherwise pretty similar otherwise.

Seems like the template errors from the yaml parser has an idx field, which my current exception regex wouldn't support..

ChristopherHX avatar Dec 02 '23 15:12 ChristopherHX