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

Go CodeGen should provide clear message for self-service trouble shooting #1484

Open
Tracked by #2070
lirenhe opened this issue Jan 7, 2025 · 3 comments
Open
Tracked by #2070
Assignees
Milestone

Comments

@lirenhe
Copy link
Member

lirenhe commented Jan 7, 2025

We need to empower our internal customer to easily trouble shooting and fix spec issues that would block the CodeGen.
This will also be helpful for external customer in the future

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, Go CodeGen just returned a big call-stack like below which will be difficult 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: (copied from #1465 (comment))

cmderr	[Go] [ERROR] ExternalError: Emitter "@azure-tools/typespec-go" crashed! This is a bug.
cmderr	[Go] [ERROR] Please file an issue at https://github.com/Azure/autorest.go/issues
cmderr	[Go] [ERROR] TypeError: Cannot read properties of undefined (reading 'flatMap')
cmderr	[Go] [ERROR] at resolvePathAndParameters (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@typespec/http/src/route.ts:78:32)
cmderr	[Go] [ERROR] at getHttpOperationInternal (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@typespec/http/src/operations.ts:217:5)
cmderr	[Go] [ERROR] at getHttpOperation (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@typespec/http/src/operations.ts:41:10)
cmderr	[Go] [ERROR] at getHttpOperationWithCache (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@azure-tools/typespec-client-generator-core/src/public-utils.ts:613:43)
cmderr	[Go] [ERROR] at updateTypesFromOperation (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@azure-tools/typespec-client-generator-core/src/types.ts:1520:25)
cmderr	[Go] [ERROR] at getAllModelsWithDiagnostics (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@azure-tools/typespec-client-generator-core/src/types.ts:1771:26)
cmderr	[Go] [ERROR] at getSdkPackage (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@azure-tools/typespec-client-generator-core/src/package.ts:568:43)
cmderr	[Go] [ERROR] at Module.createSdkContext (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/node_modules/@azure-tools/typespec-client-generator-core/src/decorators.ts:649:44)
cmderr	[Go] [ERROR] at tcgcToGoCodeModel (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/src/tcgcadapter/adapter.ts:25:33)
cmderr	[Go] [ERROR] at Object.$onEmit [as emitFunction] (file:///mnt/vss/_work/1/s/azure-sdk-for-go-pr/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/falcon/armfalcon/TempTypeSpecFiles/node_modules/@azure-tools/typespec-go/src/emitter.ts:27:27)
cmderr	[Go] [ERROR] --------------------------------------------------
cmderr	[Go] [ERROR] Library Version                0.3.0
cmderr	[Go] [ERROR] TypeSpec Compiler Version      0.62.0
cmderr	[Go] [ERROR] --------------------------------------------------
@jhendrixMSFT
Copy link
Member

Note that this particular issue isn't really self-serviceable, it's a bug in the emitter.

TypeError: Cannot read properties of undefined (reading 'flatMap')

In this case, the instructions to Please file an issue at https://github.com/Azure/autorest.go/issues is really all a customer can do.

@lirenhe
Copy link
Member Author

lirenhe commented Jan 21, 2025

Note that this particular issue isn't really self-serviceable, it's a bug in the emitter.

TypeError: Cannot read properties of undefined (reading 'flatMap')

In this case, the instructions to Please file an issue at https://github.com/Azure/autorest.go/issues is really all a customer can do.

@jhendrixMSFT, I am suggesting each emitter could have a more robust way of error handling so when customer face this error, they could know the source of the typespec and they could try to mitigate the problem instead of being blocked.

I created similar issues for all languages and here is some comments from Laurent: microsoft/typespec#5509 (comment)

@jhendrixMSFT
Copy link
Member

jhendrixMSFT commented Jan 21, 2025

Understood.

Emitter crashes are going to fall into three buckets.

  • tsp that the emitter doesn't handle
  • bugs in the emitter
  • bugs in the emitter's dependencies

I agree that for the first case the source of the problem should be clear in case customers want to modify their tsp.

For the second case, the tsp source might have already been "consumed" so there's no source to point to. e.g. if the tcgc code model has already been converted to the Go code model, and the emitter crashes during codegen, any context WRT the tsp will have been lost.

The third case will have to be handled by the dependency.

@RickWinter RickWinter modified the milestones: 2025-03, Backlog Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants