Skip to content

http-client-csharp crash on no options #9554

@timotheeguerin

Description

@timotheeguerin

Trying to run the emitter with no option gives a crash

Image
StackTrace: 
Unable to parse required option package-name from configuration.
   at Microsoft.TypeSpec.Generator.Configuration.ReadRequiredStringOption(JsonElement root, String option) in /home/runner/work/typespec/typespec/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs:line 183
   at Microsoft.TypeSpec.Generator.Configuration.Load(String outputPath, String json) in /home/runner/work/typespec/typespec/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Configuration.cs:line 120
   at Microsoft.TypeSpec.Generator.GeneratorHandler.LoadGenerator(CommandLineOptions options) in /home/runner/work/typespec/typespec/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/StartUp/GeneratorHandler.cs:line 29
   at Microsoft.TypeSpec.Generator.GeneratorRunner.RunAsync(CommandLineOptions options) in /home/runner/work/typespec/typespec/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/StartUp/GeneratorRunner.cs:line 14
   at Microsoft.TypeSpec.Generator.Program.Run(CommandLineOptions options, GeneratorRunner runner) in /home/runner/work/typespec/typespec/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/StartUp/Program.cs:line 42

    at Object.$onEmit [as emitFunction] (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/http-client-csharp/dist/emitter/src/emitter.js:89:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async runEmitter (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/program.js:715:9)
    at async file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/program.js:688:9
    at async trackAction (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/logger/console-sink.js:133:24)
    at async emit (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/program.js:686:12)
    at async compile (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/program.js:53:30)
    at async compileOnce (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/cli/actions/compile/compile.js:40:25)
    at async compileAction (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/cli/actions/compile/compile.js:23:9)
    at async Object.handler (file:///Users/timotheeguerin/dev/github/tsp-playground/node_modules/@typespec/compiler/dist/src/core/cli/utils.js:22:20)

2 issues here

  1. it shouldn't crash but report a diagnostic if it can't move forward
  2. Ideally we shouldn't make any option required and just use some default

Metadata

Metadata

Assignees

No one assigned

    Labels

    emitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions