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] Openapi client genaration fails #1521

Open
darkstarac opened this issue Oct 25, 2024 · 3 comments
Open

[Typescript] Openapi client genaration fails #1521

darkstarac opened this issue Oct 25, 2024 · 3 comments

Comments

@darkstarac
Copy link

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 => {
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 ...]

@eandre
Copy link
Member

eandre commented Oct 25, 2024

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

@darkstarac
Copy link
Author

darkstarac commented Oct 25, 2024

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 => {
return {} as Response
})

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

@compelinnovations
Copy link

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 ...]

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