Skip to content
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

TypeScript CodeGen should provide clear message for self-service trouble shooting #2979

Open
Tracked by #2070
lirenhe opened this issue Jan 7, 2025 · 0 comments
Open
Tracked by #2070
Assignees
Labels
non-azure P1 priority 1

Comments

@lirenhe
Copy link
Member

lirenhe commented Jan 7, 2025

We need to empower our customers both internal and external to easily trouble shooting and fix spec issues that would block the CodeGen.
If certain TypeSpec features or patterns are not supported by CodeGen, we should clearly point it out and suggest them to update the spec with the features we supported for CodeGen.

Today, JS CodeGen just returned a big call-stack like below which have no value for self-service resolving the problem.

I suggest we improve the following areas:

  1. Leverage TypeSpec diagnostics APIs to report the errors and provide more context so that users could easily identify the TypeSpec source that cause the error..
  2. Provide a clear message for the unsupported scenarios and ideally provide some suggestions on how to fix.

The error reported today:

Emitter "@azure-tools/typespec-ts" crashed! This is a bug.
Please file an issue at https://github.com/Azure/autorest.typescript/issues

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at getNameAndPropertyMap (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/transform/transformResponses.js:113:39)
    at transformIsDefaultSupersetOfOthers (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/transform/transformResponses.js:98:60)
    at transformToResponseTypesForRoute (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/transform/transformResponses.js:74:13)
    at transformToResponseTypes (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/transform/transformResponses.js:31:13)
    at transformRLCModel (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/transform/transform.js:31:23)
    at buildRLCCodeModels (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/index.js:134:37)
    at Object.$onEmit [as emitFunction] (file:///D:/work/typespec-example-speakeasy/node_modules/@azure-tools/typespec-ts/dist/src/index.js:82:11)
    at async runEmitter (file:///D:/work/typespec-example-speakeasy/node_modules/@typespec/compiler/dist/src/core/program.js:366:13)
    at async compile (file:///D:/work/typespec-example-speakeasy/node_modules/@typespec/compiler/dist/src/core/program.js:123:9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-azure P1 priority 1
Projects
None yet
Development

No branches or pull requests

3 participants