controller-tools icon indicating copy to clipboard operation
controller-tools copied to clipboard

panic: interface conversion: types.Type is *types.Signature, not *types.Named

Open nfyxhan opened this issue 7 months ago • 3 comments

commad: controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."

go version: 1.21.12

controller-gen version:

  • 0.9.2
  • 0.10.0
  • 0.11.0
  • ....
  • 0.17.0

controller-gen v0.4.1 - v0.8.0 is ok

panic: interface conversion: types.Type is *types.Signature, not *types.Named

goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/deepcopy.shouldBeCopied(0x400254e4e0, 0x401a43b7a0)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/deepcopy/traverse.go:622 +0x284
sigs.k8s.io/controller-tools/pkg/deepcopy.(*ObjectGenCtx).generateForPackage.func1(0x401a43b7a0)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/deepcopy/gen.go:231 +0x6c
sigs.k8s.io/controller-tools/pkg/markers.EachType.func1(0x4016f708c0, 0x401716a4c0, 0x401716a400)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/markers/zip.go:189 +0x20c
sigs.k8s.io/controller-tools/pkg/loader.(*typeVisitor).Visit(0x4014afbd00?, {0x8f3d30?, 0x401716a400?})
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/visit.go:64 +0xe8
go/ast.Walk({0x8f1780?, 0x401a333200?}, {0x8f3d30?, 0x401716a400?})
        /data/go1.21/src/go/ast/walk.go:51 +0x4c
go/ast.Walk({0x8f1780?, 0x401a333200?}, {0x8f3d80?, 0x401716a4c0?})
        /data/go1.21/src/go/ast/walk.go:344 +0x15a8
go/ast.walkDeclList(...)
        /data/go1.21/src/go/ast/walk.go:38
go/ast.Walk({0x8f1780?, 0x401a333200?}, {0x8f3d58?, 0x4016f708c0?})
        /data/go1.21/src/go/ast/walk.go:366 +0x154c
sigs.k8s.io/controller-tools/pkg/loader.EachType(0x400254e4e0, 0x401a3331e8)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/visit.go:38 +0x98
sigs.k8s.io/controller-tools/pkg/markers.EachType(0x6ff0a0?, 0x401a3f0f00?, 0x401a3f0f30)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/markers/zip.go:165 +0x84
sigs.k8s.io/controller-tools/pkg/deepcopy.(*ObjectGenCtx).generateForPackage(0x40197d1b00, 0x400254e4e0)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/deepcopy/gen.go:221 +0x204
sigs.k8s.io/controller-tools/pkg/deepcopy.Generator.Generate({{0x40001354db?, 0x5e4320?}, {0x0?, 0x772780?}}, 0x4000360410)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/deepcopy/gen.go:155 +0x188
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0x40026d0f30)
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/genall/genall.go:261 +0x228
main.main.func1(0x400032c300?, {0x400013bde0?, 0x4?, 0x7c85c2?})
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:176 +0x64
github.com/spf13/cobra.(*Command).execute(0x4000338f00, {0x40001181f0, 0x2, 0x2})
        /data/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x568
github.com/spf13/cobra.(*Command).ExecuteC(0x4000338f00)
        /data/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x318
github.com/spf13/cobra.(*Command).Execute(...)
        /data/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
        /data/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:200 +0x290

nfyxhan avatar Apr 29 '25 03:04 nfyxhan

Hi @nfyxhan do you happen to have any source code that you could share here? Clearly some type or declaration you have in your project is triggering this, but without a reproduction it will be hard to understand exactly why.

I figure we have probably overlooked that fact that you can add functions to API types (this is uncommon in core Kubernetes), but having an actual reproduction would really help being able to solve this bug

JoelSpeed avatar Apr 29 '25 12:04 JoelSpeed

It seems like the problem is here (a cast is performed without a check before the actual check happens), but i can't see the relevant snippet in the current main.

I think it has been fixed here.

MishimaPorte avatar May 07 '25 12:05 MishimaPorte

There should be a new minor release in the next few days, probably tomorrow. I would suggest to test with that again

sbueringer avatar May 07 '25 15:05 sbueringer

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Aug 05 '25 16:08 k8s-triage-robot

This was released.

Please feel free to reopen if the issue is not resolved

/close

sbueringer avatar Aug 05 '25 16:08 sbueringer

@sbueringer: Closing this issue.

In response to this:

This was released.

Please feel free to reopen if the issue is somehow not resolved

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Aug 05 '25 16:08 k8s-ci-robot