#segfault when chaining struct with custom type

1 messages ยท Page 1 of 1 (latest)

kindred coral
#

hello! does anyone run chaining function with struct that contains custom types? I have the following code that should (afaiu from the doc) allow me to chain those functions and pass around the K8sInstance struct. But I got segfault error as soon as the second function of the chain tries to use what is stored on the first one (see attached messages). Any idea on what am I doing wrong?

#
dagger call new-interlink --local-cluster tcp://localhost:59127 --kubeconfig $PWD/kubeconfig.yaml --manifests $PWD/manifests load-plugin test stdout

...

Error: response from query: input: interlink.newInterlink.loadPlugin resolve: call function "LoadPlugin": process "/runtime" did not complete successfully: exit code: 2

Stderr:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x512c38]

goroutine 1 [running]:
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.deferwrap1()
....
        /usr/local/go/src/runtime/panic.go:770 +0x124
main.(*K8sInstance).exec(0x0, {0x6663d7?, 0x40001ab668?}, {0x4000222120, 0x2e})
        /src/ci/k8s.go:164 +0x28
main.(*K8sInstance).kubectl(0x0, {0x67d6f8?, 0x40001ab6d8?})
        /src/ci/k8s.go:160 +0x78
main.(*Interlink).LoadPlugin(0x4000218490, {0x2?, 0x8?})
        /src/ci/main.go:77 +0x34
main.invoke({0x753100, 0x40001bb260}, {0x4000192548, 0x2, 0x8}, {0x40001923d0?, 0x40001ab998?}, {0x4000192480?, 0x5f6e80?}, 0x64f0e0?)
        /src/ci/dagger.gen.go:692 +0x16c
main.dispatch({0x7530c8, 0xbb6180})
        /src/ci/dagger.gen.go:639 +0x9bc
main.main()
        /src/ci/dagger.gen.go:578 +0x17c
woven sail
#

hm so is i.k8s nil at this point

#

ah i see!

#

yeah, so sadly all your struct fields need to be public

#

since json.Marshal needs them

#

that's how it works today...
but. @west granite ๐Ÿ‘€ we implement a custom MarshalJSON function for every custom struct - mayyybe there's an easy way forward to support private fields if we wanted to ๐Ÿ‘€

kindred coral
#

oh I see, thanks for the heads up! let me check if public fields fixes the issue