microsoft / typespec

https://typespec.io/
MIT License
4.44k stars 208 forks source link

[Bug]: Client python expect some properties to be defined in the tsp config and crash if they are not #4723

Open timotheeguerin opened 5 days ago

timotheeguerin commented 5 days ago

Describe the bug

Emitter "@typespec/http-client-python" crashed! This is a bug.
Please file an issue at https://github.com/microsoft/typespec/issues

TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at addDefaultOptions (file:///Users/timotheeguerin/dev/azsdk/typespec/packages/http-client-python/emitter/src/emitter.ts:48:43)
    at Object.$onEmit [as emitFunction] (file:///Users/timotheeguerin/dev/azsdk/typespec/packages/http-client-python/emitter/src/emitter.ts:81:3)
    at runEmitter (file:///Users/timotheeguerin/dev/azsdk/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/program.ts:578:7)
    at compile (file:///Users/timotheeguerin/dev/azsdk/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/program.ts:252:5)
    at compileOnce (file:///Users/timotheeguerin/dev/azsdk/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/cli/actions/compile/compile.ts:65:21)
    at compileAction (file:///Users/timotheeguerin/dev/azsdk/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/cli/actions/compile/compile.ts:31:5)

--------------------------------------------------
Library Version                0.3.0
TypeSpec Compiler Version      0.61.0
--------------------------------------------------
  1. It shoudln't crash
  2. It shouldn't require the properties(don't require the user to fill in tons of config to get the emitter working)

Reproduction

Run tsp compile . --emit "@typespec/http-client-python" in a simple main.tsp file without a tspconfig.yaml

Checklist

msyyc commented 5 days ago

Will take an investigation ASAP.

msyyc commented 2 days ago

Hi @timotheeguerin I can't reproduce the error locally. Could you try again with latest version? If the same error still occurs, please the main.tsp or the project which meets the crash issue. Thanks!

timotheeguerin commented 2 days ago

Sorry should have specified, this happens in the version in the typespec repo(not sure if you published one yet.)

For the main file it doesn't matter I just have model Foo {} in a main.tsp created right at the root of packages/http-client-python

And still happening when up to date on main(rerun npm install and npm run build)

msyyc commented 2 days ago

I see. I can reproduce it with main.tsp that only has model Foo {}. Let me take an investigation.