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

using external type results in panic #1751

Closed
jiyoonie9 opened this issue Jun 12, 2024 · 0 comments · Fixed by #1760
Closed

using external type results in panic #1751

jiyoonie9 opened this issue Jun 12, 2024 · 0 comments · Fixed by #1760
Assignees
Labels
bug Something isn't working

Comments

@jiyoonie9
Copy link

jiyoonie9 commented Jun 12, 2024

current behavior

in module A, i have this struct

type DetailResponse {
   id       string
   token token.Detail // is an external type, TypeID
   ...
}

and i built an ftl verb that returns this verb

//ftl:verb export
func GetDetails(ctx context.Context, req DetailRequest) (DetailResponse, error) {
   ...

}

when i try to do ftl build backend/modules/A i get the following stacktrace

project:shell: *[my-branch][~/IdeaProjects/MyProject]$ ftl build backend/modules/A
info:A: Building module
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x1046c6300]

goroutine 82 [running]:
github.com/TBD54566975/ftl/backend/schema.Visit.func1()
        github.com/TBD54566975/ftl/backend/schema/visit.go:8 +0x20
github.com/TBD54566975/ftl/go-runtime/compile.updateTransitiveVisibility.func1({0x0?, 0x0?}, 0x14000b24a80?)
        github.com/TBD54566975/ftl/go-runtime/compile/build.go:661 +0xe8
github.com/TBD54566975/ftl/backend/schema.Visit({0x0, 0x0}, 0x140002e52a0)
        github.com/TBD54566975/ftl/backend/schema/visit.go:7 +0x8c
github.com/TBD54566975/ftl/backend/schema.Visit.func1()
        github.com/TBD54566975/ftl/backend/schema/visit.go:9 +0x68
github.com/TBD54566975/ftl/go-runtime/compile.updateTransitiveVisibility.func1({0x105f59b38?, 0x14000d043f0?}, 0x140006cfe01?)
        github.com/TBD54566975/ftl/go-runtime/compile/build.go:661 +0xe8
github.com/TBD54566975/ftl/backend/schema.Visit({0x105f59b38, 0x14000d043f0}, 0x140002e52a0)
        github.com/TBD54566975/ftl/backend/schema/visit.go:7 +0x8c
github.com/TBD54566975/ftl/go-runtime/compile.updateTransitiveVisibility({0x105f669d8, 0x14000d043f0}, 0x140002ff180)
        github.com/TBD54566975/ftl/go-runtime/compile/build.go:658 +0xb4
github.com/TBD54566975/ftl/go-runtime/compile.updateVisibility(0x140002ff180)
        github.com/TBD54566975/ftl/go-runtime/compile/build.go:647 +0x78
github.com/TBD54566975/ftl/go-runtime/compile.ExtractModuleSchema({0x14000436c40, 0x38}, 0x140006022c0)
        github.com/TBD54566975/ftl/go-runtime/compile/build.go:639 +0x164
github.com/TBD54566975/ftl/go-runtime/compile.Build({0x105f59278, 0x1400003bd10}, {0x14000436c40, 0x38}, 0x140006022c0, {0x12dcf98a0, 0x1400047b700})
        github.com/TBD54566975/ftl/go-runtime/compile/build.go:144 +0x4e4
github.com/TBD54566975/ftl/buildengine.buildGoModule({0x105f59278?, 0x1400003bd10?}, 0x140006022c0?, {{{0x14000436c40, 0x38}, {0x140004c3278, 0x2}, {0x140004c327c, 0x4}, {0x140004c3280, ...}, ...}, ...}, ...)
        github.com/TBD54566975/ftl/buildengine/build_go.go:13 +0x70
github.com/TBD54566975/ftl/buildengine.buildModule({0x105f59278, 0x1400003bcb0}, 0x140006022c0, {{{0x14000436c40, 0x38}, {0x140004c3278, 0x2}, {0x140004c327c, 0x4}, {0x140004c3280, ...}, ...}, ...}, ...)
        github.com/TBD54566975/ftl/buildengine/build.go:58 +0x560
github.com/TBD54566975/ftl/buildengine.Build({0x105f59278?, 0x1400003bcb0?}, 0x14000127a40?, {0x105f59ba8?, 0x1400044e270?}, {0x105f54390?, 0x1400047b700?})
        github.com/TBD54566975/ftl/buildengine/build.go:33 +0xa4
github.com/TBD54566975/ftl/buildengine.(*Engine).build(0x14000146990, {0x105f59278, 0x1400003bcb0}, {0x140003fcdc0, 0x9}, 0x140004b6630, 0x14000450360)
        github.com/TBD54566975/ftl/buildengine/engine.go:569 +0x3dc
github.com/TBD54566975/ftl/buildengine.(*Engine).tryBuild(0x14000146990, {0x105f59278, 0x1400003bcb0}, 0x140005b2210, {0x140003fcdc0, 0x9}, 0x140004b6630, 0x14000450360, 0x0)
        github.com/TBD54566975/ftl/buildengine/engine.go:534 +0x2f4
github.com/TBD54566975/ftl/buildengine.(*Engine).buildWithCallback.func2()
        github.com/TBD54566975/ftl/buildengine/engine.go:480 +0x3a4
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x58
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x98

expected behavior

i would expect to ftl to give me a helpful error that says external type is not supported, something like this.

error: build and deploy failed for module "echo": /.../ftl/examples/go/echo/echo.go:29:30-36: unsupported type "invalid type" for field "TypeID"
/.../ftl/examples/go/echo/echo.go:37:2-10: unsupported type "ftl/echo.Customer" for field "Customer"
/.../ftl/examples/go/echo/echo.go:43:50-50: unsupported response type "ftl/echo.EchoResponse"

other notes

we were not able to recreate this error when using the echo module inside ftl repo's example directory.

@github-actions github-actions bot added the triage Issue needs triaging label Jun 12, 2024
@ftl-robot ftl-robot mentioned this issue Jun 12, 2024
@alecthomas alecthomas added the bug Something isn't working label Jun 12, 2024
@jonathanj-square jonathanj-square removed the triage Issue needs triaging label Jun 12, 2024
wesbillman pushed a commit that referenced this issue Jun 13, 2024
fixes #1751

We were hitting the above issue because we were trying to traverse the
schema tree to implicitly export nodes, but were encountering a verb
which added nil values into its children slice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants