go – CFG post-order panic: reflect: embedded type with methods not implemented if there is more than one field

I am trying to build a Traefik plugin and test it in local mode based on https://github.com/traefik/plugindemo#local-mode

In this plugin, I am trying to use a library https://github.com/vektah/gqlparser

Without importing this library, the code runs well. As long as I added

import (
    "github.com/vektah/gqlparser"
)

_ = gqlparser.MustLoadSchema

The full code:

package traefik_plugin_validate_graphql_query

import (
    "context"
    "net/http"
    "github.com/vektah/gqlparser"
)

type Config struct{}

func CreateConfig() *Config {
    return &Config{}
}

type ValidateGraphQLQuery struct {
    next http.Handler
    name string
}

func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error) {
    return &ValidateGraphQLQuery{
        next: next,
        name: name,
    }, nil
}

func (a *ValidateGraphQLQuery) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
    _ = gqlparser.MustLoadSchema
    rw.Write([]byte("hello"))
}

Then run

go mod vendor
traefik --configfile=traefik.yaml

I got this error

INFO[0000] Configuration loaded from file: /traefik.yaml
INFO[2022-06-17T17:07:19-07:00] Traefik version 2.6.6 built on I don't remember exactly
DEBU[2022-06-17T17:07:19-07:00] Static configuration loaded {"global":{"checkNewVersion":true},"serversTransport":{"maxIdleConnsPerHost":200},"entryPoints":{"hasura-entrypoint":{"address":":9001","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}},"traefik":{"address":":8080","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}}},"providers":{"providersThrottleDuration":"2s","file":{"watch":true,"filename":"dynamic_conf.yaml"}},"api":{"insecure":true,"dashboard":true},"log":{"level":"DEBUG","format":"common"},"pilot":{"dashboard":true},"experimental":{"localPlugins":{"traefik-plugin-validate-graphql-query":{"moduleName":"github.com/Hongbo-Miao/traefik-plugin-validate-graphql-query"}}}}
INFO[2022-06-17T17:07:19-07:00]
Stats collection is disabled.
Help us improve Traefik by turning this feature on :)
More details on: https://doc.traefik.io/traefik/contributing/data-collection/
panic: reflect: embedded type with methods not implemented if there is more than one field [recovered]
    panic: plugins-local/src/github.com/Hongbo-Miao/traefik-plugin-validate-graphql-query/vendor/github.com/vektah/gqlparser/ast/dumper.go:15:7: CFG post-order panic: reflect: embedded type with methods not implemented if there is more than one field

goroutine 1 [running]:
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func2.1()
    github.com/traefik/yaegi@v0.11.3/interp/cfg.go:475 +0x78
panic({0x688ff20, 0x7a4bbb0})
    runtime/panic.go:838 +0x207
reflect.StructOf({0xc000c05520, 0x2, 0xc000bc1da0?})
    reflect/type.go:2554 +0x23c6
github.com/traefik/yaegi/interp.(*itype).refType(0xc000a82ff0?, 0x70f08a4?)
    github.com/traefik/yaegi@v0.11.3/interp/type.go:1831 +0x973
github.com/traefik/yaegi/interp.(*itype).TypeOf(...)
    github.com/traefik/yaegi@v0.11.3/interp/type.go:1870
github.com/traefik/yaegi/interp.(*itype).frameType(0x0?)
    github.com/traefik/yaegi@v0.11.3/interp/type.go:1899 +0x227
github.com/traefik/yaegi/interp.(*scope).add(0xc000c07050, 0xc000a5fd18?)
    github.com/traefik/yaegi@v0.11.3/interp/scope.go:223 +0x7b
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func2(0xc000a9a360)
    github.com/traefik/yaegi@v0.11.3/interp/cfg.go:1116 +0x82c5
github.com/traefik/yaegi/interp.(*node).Walk(0xc000a9a360, 0xc000cd8658, 0xc000cd8620)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:292 +0xad
github.com/traefik/yaegi/interp.(*node).Walk(0xc000a9a120, 0xc000cd8658, 0xc000cd8620)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc000a997a0, 0xc000cd8658, 0xc000cd8620)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc000a98a20, 0xc000cd8658, 0xc000cd8620)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc000a63b00, 0xc000cd8658, 0xc000cd8620)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*Interpreter).cfg(0xc000430480, 0xc000a63b00, 0xc000c07050, {0xc0008cd981, 0x1f}, {0xc000455260, 0x3})
    github.com/traefik/yaegi@v0.11.3/interp/cfg.go:62 +0x285
github.com/traefik/yaegi/interp.(*Interpreter).importSrc(0xc000430480, {0xc00010ed20, 0x6c}, {0xc0008cd981, 0x1f}, 0x1)
    github.com/traefik/yaegi@v0.11.3/interp/src.go:125 +0x6d6
github.com/traefik/yaegi/interp.(*Interpreter).gta.func1(0xc00095a900)
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:237 +0x1daa
github.com/traefik/yaegi/interp.(*node).Walk(0xc00095a900, 0xc000cd93c8, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:285 +0x34
github.com/traefik/yaegi/interp.(*node).Walk(0xc00095a7e0, 0xc000cd93c8, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc00095a5a0, 0xc000cd93c8, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*Interpreter).gta(0xc000430480, 0xc00095a5a0, {0xc00010ed20, 0x6c}, {0xc0004db561, 0x1b}, {0xc0005fbcb0, 0x9})
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:20 +0x22b
github.com/traefik/yaegi/interp.(*Interpreter).importSrc(0xc000430480, {0xc000158500, 0x49}, {0xc0004db561, 0x1b}, 0x1)
    github.com/traefik/yaegi@v0.11.3/interp/src.go:108 +0xf8a
github.com/traefik/yaegi/interp.(*Interpreter).gta.func1(0xc0005bfc20)
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:237 +0x1daa
github.com/traefik/yaegi/interp.(*node).Walk(0xc0005bfc20, 0xc000cda160, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:285 +0x34
github.com/traefik/yaegi/interp.(*node).Walk(0xc0005bf440, 0xc000cda160, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc0005bf200, 0xc000cda160, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*Interpreter).gta(0xc000430480, 0xc0005bf200, {0xc000158500, 0x49}, {0xc0001583c1, 0x49}, {0xc0008cd8f0, 0x25})
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:20 +0x22b
github.com/traefik/yaegi/interp.(*Interpreter).importSrc(0xc000430480, {0xc0005fb408, 0x4}, {0xc0001583c1, 0x49}, 0x1)
    github.com/traefik/yaegi@v0.11.3/interp/src.go:108 +0xf8a
github.com/traefik/yaegi/interp.(*Interpreter).gta.func1(0xc0005befc0)
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:237 +0x1daa
github.com/traefik/yaegi/interp.(*node).Walk(0xc0005befc0, 0xc000cdaef8, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:285 +0x34
github.com/traefik/yaegi/interp.(*node).Walk(0xc0005beea0, 0xc000cdaef8, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc0005bec60, 0xc000cdaef8, 0x0)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:289 +0x75
github.com/traefik/yaegi/interp.(*Interpreter).gta(0xc000430480, 0xc0005bec60, {0xc0005fb408, 0x4}, {0xc0005fb408, 0x4}, {0xc0005fb408, 0x4})
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:20 +0x22b
github.com/traefik/yaegi/interp.(*Interpreter).gtaRetry(0xc000430480?, {0xc000cdb0d8?, 0xc0005e3000?, 0xc000cdb020?}, {0xc0005fb408, 0x4}, {0xc0005fb408, 0x4})
    github.com/traefik/yaegi@v0.11.3/interp/gta.go:346 +0x155
github.com/traefik/yaegi/interp.(*Interpreter).CompileAST(0xc000430480, {0x7a5d0d0?, 0xc0005e3000?})
    github.com/traefik/yaegi@v0.11.3/interp/program.go:77 +0x17f
github.com/traefik/yaegi/interp.(*Interpreter).compileSrc(0xc000430480, {0xc000119560?, 0x1?}, {0x0?, 0xc000119560?}, 0xd0?)
    github.com/traefik/yaegi@v0.11.3/interp/program.go:52 +0xb8
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc000430480, {0xc000119560?, 0xc000cdb348?}, {0x0?, 0x1?}, 0x0?)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:606 +0x28
github.com/traefik/yaegi/interp.(*Interpreter).Eval(...)
    github.com/traefik/yaegi@v0.11.3/interp/interp.go:492
github.com/traefik/traefik/v2/pkg/plugins.NewBuilder(0x0, 0x0?, 0xffffffffffffffff?)
    github.com/traefik/traefik/v2/pkg/plugins/builder.go:104 +0xdc6
main.createPluginBuilder(0xc0005e2780?)
    github.com/traefik/traefik/v2/cmd/traefik/plugins.go:18 +0x35
main.setupServer(0xc0005e2780)
    github.com/traefik/traefik/v2/cmd/traefik/traefik.go:224 +0x5cd
main.runCmd(0xc0005e2780)
    github.com/traefik/traefik/v2/cmd/traefik/traefik.go:116 +0x3df
main.main.func1({0xc00020af40?, 0xc00013a010?, 0x8?})
    github.com/traefik/traefik/v2/cmd/traefik/traefik.go:61 +0x1f
github.com/traefik/paerser/cli.run(0xc0005e2800, {0xc00013a010?, 0x1?, 0x1?})
    github.com/traefik/paerser@v0.1.5/cli/commands.go:133 +0x193
github.com/traefik/paerser/cli.execute(0xc0005e2800, {0xc00013a000?, 0x2, 0x2}, 0xa0?)
    github.com/traefik/paerser@v0.1.5/cli/commands.go:67 +0x2cc
github.com/traefik/paerser/cli.Execute(...)
    github.com/traefik/paerser@v0.1.5/cli/commands.go:51
main.main()
    github.com/traefik/traefik/v2/cmd/traefik/traefik.go:77 +0x3fc

In this error log, there is a line which might help locate the issue:

panic: plugins-local/src/github.com/Hongbo-Miao/traefik-plugin-validate-graphql-query/vendor/github.com/vektah/gqlparser/ast/dumper.go:15:7: CFG post-order panic: reflect: embedded type with methods not implemented if there is more than one field

The content of this dumper.go can be found at https://github.com/vektah/gqlparser/blob/master/ast/dumper.go

I searched this error online but cannot find any useful info.

What does this error mean? Thanks!

Leave a Comment