encore icon indicating copy to clipboard operation
encore copied to clipboard

[Typescript] Openapi client genaration fails

Open darkstarac opened this issue 1 year ago • 5 comments

interface A {} interface B {} interface Response { data: A | B }

export const api_call = api( { expose: true, auth: true, method: "GET", path: "/api/creatives" }, async (): Promise<Response> => { return {} as Response })

error: ── Internal compiler error ────────────────────────────────────────────────────────────────[E0001]──

An unhandled panic occurred in the Encore compiler: runtime error: invalid memory address or nil pointer dereference

This is a bug in Encore and should not have occurred. Please report this issue to the Encore team either on Github at https://github.com/encoredev/encore/issues/new and include this error.

╭─[Stack Trace] ├─▶ clientgen.Client.func1 encr.dev/internal/clientgen/client.go:65 ├─▶ openapi.(*Generator).Generate.func1 encr.dev/internal/clientgen/openapi/openapi.go:54 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:293 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:293 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:293 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:293 ╰─[... remaining frames omitted ...]

darkstarac avatar Oct 25 '24 08:10 darkstarac

Does this work when you run encore run? The syntax looks wrong to me. You want async (): Promise<Response>, no?

eandre avatar Oct 25 '24 08:10 eandre

Yes you are right. My fault it was a typo.

interface A {} interface B {} interface Response { data: A | B }

export const api_call = api( { expose: true, auth: true, method: "GET", path: "/api/api_call" }, async (): Promise<Response> => { return {} as Response })

Works with: encore run. Fails with: encore gen client app-name --lang=openapi --output=./openapi.json --env=local

darkstarac avatar Oct 25 '24 08:10 darkstarac

Getting the same error, worked fine initially but after running it a couple of times this pops up.

error: ── Internal compiler error ────────────────────────────────────────────────────────────────[E0001]──

An unhandled panic occurred in the Encore compiler: runtime error: invalid memory address or nil pointer dereference

This is a bug in Encore and should not have occurred. Please report this issue to the Encore team either on Github at https://github.com/encoredev/encore/issues/new and include this error.

╭─[Stack Trace] ├─▶ clientgen.Client.func1 encr.dev/internal/clientgen/client.go:65 ├─▶ openapi.(*Generator).Generate.func1 encr.dev/internal/clientgen/openapi/openapi.go:54 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:294 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:294 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:294 ├─▶ json.(*encodeState).marshal.func1 encoding/json/encode.go:294 ╰─[... remaining frames omitted ...]

compelinnovations avatar Nov 16 '24 06:11 compelinnovations

any updates on this one?

Google4777 avatar Mar 07 '25 16:03 Google4777

Good day - was having this issue however it was a naming issue. i had "third-party" as the folder name which showed up as "third_party" when importing the service. renaming to "third_party" with underscore instead of the dash fixed the issue for me

willroyMyles avatar Nov 13 '25 14:11 willroyMyles