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

lint panic with option features.(pb.go).api_level #3580

Closed
espadolini opened this issue Jan 10, 2025 · 1 comment · Fixed by #3594
Closed

lint panic with option features.(pb.go).api_level #3580

espadolini opened this issue Jan 10, 2025 · 1 comment · Fixed by #3594
Labels
Bug Something isn't working

Comments

@espadolini
Copy link

GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)

https://github.com/espadolini/buflintrepro

Commands

buf lint

Output

panic: invalid type: got *dynamicpb.Message, want *gofeaturespb.GoFeatures

goroutine 1 [running]:
google.golang.org/protobuf/internal/impl.(*messageConverter).GoValueOf(0x140000ef180, {{}, 0x1063fa9e0?, 0x140003230c0?, 0x1064dab50?})
        google.golang.org/[email protected]/internal/impl/convert.go:457 +0x3a4
google.golang.org/protobuf/internal/impl.(*ExtensionInfo).InterfaceOf(0x140006b8600?, {{}, 0x1063fa9e0?, 0x140003230c0?, 0x105503780?})
        google.golang.org/[email protected]/internal/impl/extension.go:102 +0x60
google.golang.org/protobuf/proto.GetExtension({0x10647a100?, 0x140006b8600?}, {0x1064a0cb0, 0x1073d57c0})
        google.golang.org/[email protected]/proto/extension.go:90 +0xf8
google.golang.org/protobuf/reflect/protodesc.mergeEditionFeatures({0x1064a82a0?, 0x14001bbbc20?}, 0x0?)
        google.golang.org/[email protected]/reflect/protodesc/editions.go:128 +0x170
google.golang.org/protobuf/reflect/protodesc.initFileDescFromFeatureSet(0x14001bbbc20, 0x140006b8600)
        google.golang.org/[email protected]/reflect/protodesc/editions.go:152 +0x90
google.golang.org/protobuf/reflect/protodesc.FileOptions.New({{}, 0x80?}, 0x1400032a300, {0x1064831a8?, 0x14000c92cd8?})
        google.golang.org/[email protected]/reflect/protodesc/desc.go:126 +0x448
google.golang.org/protobuf/reflect/protodesc.FileOptions.addFileDeps({{}, 0x58?}, 0x14000c92cd8, 0x1400032a300, 0x14001087228)
        google.golang.org/[email protected]/reflect/protodesc/desc.go:287 +0x1ec
google.golang.org/protobuf/reflect/protodesc.FileOptions.NewFiles({{}, 0x40?}, 0x14001087360)
        google.golang.org/[email protected]/reflect/protodesc/desc.go:264 +0x26c
google.golang.org/protobuf/reflect/protodesc.NewFiles(...)
        google.golang.org/[email protected]/reflect/protodesc/desc.go:76
buf.build/go/bufplugin/descriptor.FileDescriptorsForProtoFileDescriptors({0x14000ee3560, 0x4, 0x140019e2308?})
        buf.build/go/[email protected]/descriptor/file_descriptor.go:91 +0x24c
github.com/bufbuild/buf/private/bufpkg/bufcheck.(*client).Lint(0x140005ad230, {0x10648bb90, 0x140003b8000}, {0x1064c93b0, 0x1073c05c0}, {0x12f0e55a0, 0x14000834780}, {0x14000c892a0, 0x2, 0x1400058ff80?})
        github.com/bufbuild/[email protected]/private/bufpkg/bufcheck/client.go:112 +0x1c0
github.com/bufbuild/buf/private/buf/cmd/buf/command/lint.run({0x10648bb90, 0x140003b8000}, {0x1064c3a80, 0x140002c8080}, 0x140003b92d0)
        github.com/bufbuild/[email protected]/private/buf/cmd/buf/command/lint/lint.go:160 +0x8e8
github.com/bufbuild/buf/private/buf/cmd/buf/command/lint.NewCommand.func1({0x10648bb90?, 0x140003b8000?}, {0x1064c3a80?, 0x140002c8080?})
        github.com/bufbuild/[email protected]/private/buf/cmd/buf/command/lint/lint.go:55 +0x30
github.com/bufbuild/buf/private/buf/cmd/buf.NewRootCommand.newErrorInterceptor.func3.1({0x10648bb90?, 0x140003b8000?}, {0x1064c3a80?, 0x140002c8080?})
        github.com/bufbuild/[email protected]/private/buf/cmd/buf/buf.go:395 +0x34
github.com/bufbuild/buf/private/pkg/app/appext.(*builder).run(0x1400068d5e0, {0x106490e78, 0x14000164800}, {0x10649c790, 0x1400054c500}, 0x1400058e0e0)
        github.com/bufbuild/[email protected]/private/pkg/app/appext/builder.go:140 +0x358
github.com/bufbuild/buf/private/pkg/app/appext.(*builder).NewRunFunc.func1({0x106490e78, 0x14000164800}, {0x10649c790, 0x1400054c500})
        github.com/bufbuild/[email protected]/private/pkg/app/appext/builder.go:100 +0x74
github.com/bufbuild/buf/private/pkg/app/appcmd.commandToCobra.func2(0x1400020b000?, {0x10741af00?, 0x0, 0x105c529eb?})
        github.com/bufbuild/[email protected]/private/pkg/app/appcmd/appcmd.go:326 +0x1f8
github.com/spf13/cobra.(*Command).execute(0x14000590c08, {0x10741af00, 0x0, 0x0})
        github.com/spf13/[email protected]/command.go:989 +0x81c
github.com/spf13/cobra.(*Command).ExecuteC(0x14000590008)
        github.com/spf13/[email protected]/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:1041
github.com/bufbuild/buf/private/pkg/app/appcmd.run({0x106490e78, 0x14000164800}, {0x10649c790, 0x1400054ce60}, 0x1400016cdd0)
        github.com/bufbuild/[email protected]/private/pkg/app/appcmd/appcmd.go:270 +0x7c0
github.com/bufbuild/buf/private/buf/cmd/buf.Main.Main.newRunFunc.func1({0x106490e78?, 0x14000164800?}, {0x10649c790?, 0x1400054ce60?})
        github.com/bufbuild/[email protected]/private/pkg/app/appcmd/appcmd.go:132 +0x30
github.com/bufbuild/buf/private/pkg/app.Run({0x10648bab0?, 0x10741af00?}, {0x10649c790, 0x1400054ce60}, 0x14000119f08)
        github.com/bufbuild/[email protected]/private/pkg/app/app.go:329 +0x48
github.com/bufbuild/buf/private/pkg/app.Main({0x10648bab0, 0x10741af00}, 0x14000119f08)
        github.com/bufbuild/[email protected]/private/pkg/app/app.go:321 +0x74
github.com/bufbuild/buf/private/pkg/app/appcmd.Main(...)
        github.com/bufbuild/[email protected]/private/pkg/app/appcmd/appcmd.go:105
github.com/bufbuild/buf/private/buf/cmd/buf.Main({0x105c520b6?, 0x140000021c0?})
        github.com/bufbuild/[email protected]/private/buf/cmd/buf/buf.go:117 +0x48
main.main()
        github.com/bufbuild/[email protected]/cmd/buf/main.go:20 +0x28

Expected Output

I expected no panic.

Anything else?

No response

@espadolini espadolini added the Bug Something isn't working label Jan 10, 2025
emcfarlane added a commit that referenced this issue Jan 14, 2025
This fixes the handling of the Go feature set in editions for use with
checks. Dynamic types would cause the google.golang.org/protobuf
library to panic when trying to fetch the Go feature extension. This is
a temporary workaround until upstream can be resolved. See the issue:
golang/protobuf#1669

When resolving file descriptors for checks, we now check for use of
google/protobuf/go_features.proto and reparse extensions with a resolver
targetted at the gofeaturespb package. This ensure the types will match
the ones set in the extension type gofeaturespb.E_go.

Fixes #3580
@emcfarlane
Copy link
Contributor

@espadolini thanks for the issue! We have a workaround for the bug with the upstream issue being in the protobuf-go library. See golang/protobuf#1669 . It looks like a fix will be upstreamed soon, so we are planning to wait for the library change before updating and creating a new release.

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
2 participants