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

Enhance type error messages #97

Open
pehala opened this issue Jun 28, 2024 · 0 comments
Open

Enhance type error messages #97

pehala opened this issue Jun 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@pehala
Copy link

pehala commented Jun 28, 2024

If you use wrong type in x-kuadrant extensions, kuadrantctl will panic and write cannot unmarshal object into Go struct field and the entire stacktrace, which makes it hard to deduce what exactly is wrong if you never encounter similar error in Go before and the message itself does not give that many pointers either.

Example messages:
(Parent reference is not a list)

panic: json: cannot unmarshal object into Go struct field RouteObject.x-kuadrant.route.parentRefs of type []v1.ParentReference  goroutine 1 [running]: github.com/kuadrant/kuadrantctl/pkg/gatewayapi.HTTPRouteObjectMetaFromOAS(0xc000195b48?) 	/home/phala/kuadrantctl/pkg/gatewayapi/http_route.go:15 +0x1b6 github.com/kuadrant/kuadrantctl/cmd.buildHTTPRoute(0xc0001d3290) 	/home/phala/kuadrantctl/cmd/generate_gatewayapi_httproute.go:85 +0xa9 github.com/kuadrant/kuadrantctl/cmd.runGenerateGatewayApiHttpRoute(0xc00018d508, {0x182567a?, 0x4?, 0x182567e?}) 	/home/phala/kuadrantctl/cmd/generate_gatewayapi_httproute.go:59 +0x10f github.com/spf13/cobra.(*Command).execute(0xc00018d508, {0xc0000a79c0, 0x2, 0x2}) 	/home/phala/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xaca github.com/spf13/cobra.(*Command).ExecuteC(0xc000276c08) 	/home/phala/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff github.com/spf13/cobra.(*Command).Execute(0xc00013a130?) 	/home/phala/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0x13 main.main() 	/home/phala/kuadrantctl/main.go:27 +0x4a

(Path level x-kuadrant is a list instead of a dict)

panic: json: cannot unmarshal array into Go struct field KuadrantOASPathObject.x-kuadrant of type utils.KuadrantOASPathExtension

goroutine 1 [running]:
github.com/kuadrant/kuadrantctl/pkg/gatewayapi.HTTPRouteRulesFromOAS(0xc0003342d0)
	/home/phala/kuadrantctl/pkg/gatewayapi/http_route.go:90 +0x57a
github.com/kuadrant/kuadrantctl/cmd.buildHTTPRoute(0xc0003342d0)
	/home/phala/kuadrantctl/cmd/generate_gatewayapi_httproute.go:91 +0x12f
github.com/kuadrant/kuadrantctl/cmd.runGenerateGatewayApiHttpRoute(0xc000423808, {0x182567a?, 0x4?, 0x182567e?})
	/home/phala/kuadrantctl/cmd/generate_gatewayapi_httproute.go:59 +0x10f
github.com/spf13/cobra.(*Command).execute(0xc000423808, {0xc0002fe740, 0x2, 0x2})
	/home/phala/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000422008)
	/home/phala/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0xc00013a130?)
	/home/phala/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0x13
main.main()
	/home/phala/kuadrantctl/main.go:27 +0x4a

@pehala pehala added the enhancement New feature or request label Jun 28, 2024
@pehala pehala added this to Kuadrant Jun 28, 2024
@pehala pehala changed the title Enhance wrong type error messages Enhance type error messages Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant