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

[BUG] go module check update for buf package failed #3453

Closed
solarhell opened this issue Nov 7, 2024 · 6 comments
Closed

[BUG] go module check update for buf package failed #3453

solarhell opened this issue Nov 7, 2024 · 6 comments
Assignees
Labels
Bug Something isn't working

Comments

@solarhell
Copy link

solarhell commented Nov 7, 2024

How to reproduce

https://sum.golang.org/lookup/buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/[email protected]

Output

not found: buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/[email protected]: reading https://buf.build/gen/go/buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/go/@v/v1.17.0-20240829202630-d59b7d45e69d.1.zip: 400 Bad Request
	server response: generating files: invalid_argument: plugin "buf.build/connectrpc/go:v1.17.0" exited with non-zero status 1: protoc-gen-connect-go: unable to determine Go import path for "google/protobuf/cpp_features.proto"

Expected Output

something like this

https://sum.golang.org/lookup/golang.org/x/[email protected]

30629555
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=

go.sum database tree
31465925
o2YqmsR/07bA4UH1xIFDEKC/Ue8LQMFM3w/58zAQV6c=

— sum.golang.org Az3grseXe9LdN4DYVxObtPAPFOdsY7pxJHh3CMtSGKHHjcFh4GR1T5xNy2ABLTnswaSo5OyT9RJ/1sv6ah0cooo0zQA=

Anything else?

No response

@solarhell solarhell added the Bug Something isn't working label Nov 7, 2024
@solarhell solarhell changed the title [BUG] go module check buf package update failed [BUG] go module check update for buf package failed Nov 7, 2024
@doriable
Copy link
Member

doriable commented Nov 7, 2024

Hello, thanks for filing this issue. This is occurring because we added cpp_features.proto and java_features.proto files which do not have the go package option defined.

That being said, if you are looking to work with well-known types and Go code, they are available already in the Go protobuf runtime: https://pkg.go.dev/google.golang.org/protobuf/types/[email protected].

I also noted that you are attempting to generate this with connect-go -- there are no RPC services for well-known types, which is what the connect-go plugin is used to generate, so you should not be using the plugin with the well-known type protobuf definitions.

@solarhell
Copy link
Author

Thanks for the reply, I am indeed using connect-go and have added googleapis and wellknowntypes to the deps of buf.yaml. What should I tweak to avoid generating code for wellknowntypes?

FYI,this my is my current config

buf.yaml

version: v2
modules:
  - path: .
    name: buf.build/wolodata/api
lint:
  use:
    - STANDARD
  except:
    - FIELD_NOT_REQUIRED
    - PACKAGE_NO_IMPORT_CYCLE
  disallow_comment_ignores: true
breaking:
  use:
    - FILE
  except:
    - EXTENSION_NO_DELETE
    - FIELD_SAME_DEFAULT
deps:
    - buf.build/googleapis/googleapis
    - buf.build/protocolbuffers/wellknowntypes

and buf.gen.yaml

version: v2
managed:
  enabled: true
  override:
    - file_option: go_package_prefix
      value: github.com/wolodata/proto/gen
plugins:
  - remote: buf.build/protocolbuffers/go:v1.35.1
    out: gen
    opt:
      - paths=source_relative
  - remote: buf.build/connectrpc/go:v1.17.0
    out: gen
    opt:
      - paths=source_relative
  - remote: buf.build/connectrpc/es:v1.5.0
    out: gen
  - remote: buf.build/bufbuild/es:v1.10.0
    out: gen

@doriable
Copy link
Member

doriable commented Nov 8, 2024

Ah okay, I see, thank you for providing this context! So if you are using the well-known types as a part of your proto definitions, you don't actually need to provide the buf.build/protocolbuffers/wellknowntypes module, you get them for free as part of the compilation. There is a small quote in the well-known types module documentation on this:

Even without depending on this module, you can use these files out of the box.

So unless you have a special use-case (as outlined in the README), you can simply remove that from your deps.
Let me know if this helps! That being said, we are also still looking into the issue with the Go module internally.

@solarhell
Copy link
Author

solarhell commented Nov 11, 2024

Thanks for you reply.

I tried removing buf.build/protocolbuffers/wellknowntypes from the deps of buf.yaml, and when I run buf lint, the warning suggests that

WARN    File "permission/v1/permission.proto" imports "google/protobuf/descriptor.proto", which is not in your workspace or in the dependencies declared in your buf.yaml, but is found in transitive dependency "buf.build/protocolbuffers/wellknowntypes".
Declare "buf.build/protocolbuffers/wellknowntypes" in the deps key in your buf.yaml.
WARN    File "article/v1/article.proto" imports "google/protobuf/wrappers.proto", which is not in your workspace or in the dependencies declared in your buf.yaml, but is found in transitive dependency "buf.build/protocolbuffers/wellknowntypes".
Declare "buf.build/protocolbuffers/wellknowntypes" in the deps key in your buf.yaml.

And the generated connect-rpc code still requires buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/go.

module buf.build/gen/go/wolodata/api/connectrpc/go

go 1.21

require (
	buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/go v1.17.0-20240829202630-d59b7d45e69d.1
	buf.build/gen/go/wolodata/api/protocolbuffers/go v1.34.2-20241111085537-48f371483e91.2
	connectrpc.com/connect v1.17.0
)

And check the code, i can see that the buf.build/gen/go/protocolbuffers/wellknowntypes/protocolbuffers/go is not used.

image image

@doriable
Copy link
Member

So I did a little digging into your issue by checking your module on buf.build/wolodata/api. Because you added the buf.build/protocolbuffers/wellknowntypes dependency in the past, it is not being pruned from your buf.lock, even though it is removed from your buf.yaml.

In this case, the easiest solution will be to remove your buf.lock entirely and then run buf dep update with your new buf.yaml without the dependency on buf.build/protocolbuffers/wellknowntypes. This will pick up any updates to googleapis, but you are already depending on the latest version. This will now remove your dependency entirely on the well-known types module, and should no longer pick this up in your generated code.

Let me know if this helps!

@doriable doriable self-assigned this Nov 11, 2024
@solarhell
Copy link
Author

solarhell commented Nov 12, 2024

After removing buf.lock and updated the deps, it works fine. Thank you for your generous help.

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
Development

No branches or pull requests

2 participants