protobuf: Rev of proto-gen-go to ProtoPackageIsVersion3 causing breakage
I am hopeful that there is a simple solution to get around this issue 😃
A few hours ago, this commit introduced proto.ProtoPackageIsVersion3
and set const generatedCodeVersion = 3
Our CI system (and I suspect many other peoples) do a:
go get github.com/golang/protobuf/protoc-gen-go
as part of setting up the system, and also do a:
go generate ./…
and check to make sure that regenerated files match the files in the commit (basically, checking for regen on updating the .proto files).
This has been going swimmingly until a few hours ago. In trying to debug this problem, I came to realize that the fact this worked at all is a testament to how good you guys are at backward compatibility 👍
What I discovered digging in is that we have been vendoring github.com/golang/protobuf/ v1.2.0 (because of other dependencies we have), but of course go get pulls the latest from master.
v1.2.0 lacks proto.ProtoPackageIsVersion3, so our generated code suddenly doesn’t compile.
So I fell back to using:
go install ./vendor/github.com/golang/protobuf/protoc-gen-go/
in our CI. Unfortunately, this seems to result in some generation differences. If I run it locally, push, and then our CI runs it, the generated code doesn’t quite match.
I get diffs like:
-var fileDescriptor_networkservice_d4de7ff5f5769d53 = []byte{
+var fileDescriptor_networkservice_5b085879d0d87bdf = []byte{
I don’t precisely consider this a bug on your end, you guys are super good about backward compatibility, and at some point you do have to make the change.
Do you have any ideas about how I might navigate all of this? I suspect lots and lots of folks will shortly have similar issues…
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 34
- Comments: 60 (18 by maintainers)
Commits related to this issue
- NetworkServiceServer/NetworkService client. (#522) * 1. usage of NetworkServiceDiscovery 2. services registry to do connections to internal services 3. services apiRegistry for starting up network ... — committed to networkservicemesh/networkservicemesh by haiodo 6 years ago
- protoc-gen-go: generate XXX_OneofWrappers instead of XXX_OneofFuncs (#760) The marshaler, unmarshaler, and sizer functions are unused ever since the underlying implementation was switched to be tabl... — committed to golang/protobuf by dsnet 6 years ago
- Add note to README on responsible CI usage. This is in the hopes of easing folks hitting #763 in getting to a proper use of CI. Signed-off-by: Ed Warnicke <hagbard@gmail.com> — committed to edwarnicke/protobuf by edwarnicke 6 years ago
- Try forcing proto-gen-go to 1.2.0, per https://github.com/golang/protobuf/issues/763#issuecomment-443760051 — committed to sboagibm/ffdl-trainer by deleted user 6 years ago
- Restrict protobuf to latest released version protobuf recently introduced a change in master that makes it incompatible with the latest release. To prevent breakage, use latest released version of pr... — committed to SKF/proto by j0s 6 years ago
- Restrict protobuf version to v1.2.0 (#49) protobuf recently introduced a change in master that makes it incompatible with the latest release. To prevent breakage, use latest released version of pro... — committed to SKF/proto by j0s 6 years ago
- Vendor github.com/golang/protobuf Peg at commit 8d0c54c1246661d9a51ca0ba455d22116d485eaa in order to avoid https://github.com/golang/protobuf/issues/763. — committed to harmony-one/harmony by deleted user 5 years ago
- Add modules This adds modules support so that we know what versions of our various tools we are tracking. Note that there are a lot of indirect dependencies added on part of the fact we are pinning ... — committed to hashicorp/sentinel-sdk by vancluever 5 years ago
- Recompiled everything with a pinned protoc-gen-go@v1.2.0 look at:https://github.com/golang/protobuf/issues/763 for details — committed to CSUNetSec/netsec-protobufs by ramrunner 5 years ago
- Update protoc-gen-go (#200) To fix https://github.com/golang/protobuf/issues/763 Signed-off-by: Keith Smiley <keithbsmiley@gmail.com> — committed to bufbuild/protoc-gen-validate by keith 5 years ago
- protobuf: match protoc-gen-go to the protobuf version The Go protoc plugin (protoc-gen-go) and the protobuf package itself need to match versions. The previous Makefile installed the master version o... — committed to jchampio/gpupgrade by jchampio 5 years ago
- protobuf: match protoc-gen-go to the protobuf version The Go protoc plugin (protoc-gen-go) and the protobuf package itself need to match versions. The previous Makefile installed the master version o... — committed to kalensk/gpupgrade by jchampio 5 years ago
depusers should version theirprotoc-gen-goas a required binary, like so (inGopkg.toml):You can then install
protoc-gen-gofrom vendor:I’m not sure what the go modules equivalent workflow is.
@johanbrandhorst @edwarnicke @lavoiesl If any of you guys happen to be using go modules- this worked for me: go get github.com/golang/protobuf@8d0c54c1246661d9a51ca0ba455d22116d485eaa ^^^ that will update your go.mod to use the specific revision needed to avoid problems
I could fix the dependency issue in this way:
Thanks @lenvs inspired me! I also solved the problem ! You may do that.
Stay in branch master, don`t checkout to V1.2.0 !!!
This hack worked for me
problem solved. This is because proto-go is installed by
go get -u github.com/golang/protobuf/protoc-gen-go, which is the newest master branch. you can switch to tag 1.2.0. reinstall proto-go, reprotoc all files will fix this problem.I want to note some caveats with https://github.com/golang/protobuf/issues/763#issuecomment-452153894 suggestion:
protoc-gen-gofrom head, but have a specific version of theprotopackage pinned.protopackage to a more recent version closer to today’s head, but doesn’t address underlying problem; that is, you are still buildingprotoc-gen-gofrom head, but have a specific version ofprotopinned.protoc-gen-go, which is a more stable path forward, than to still build the binary from head.I’m also a bit embarrassed that our CI got caught by this too.
go get -u github.com/golang/protobuf/protoc-gen-gowas just too convenient.Something that could be helpful coming from the golang/protobuf side is to put binaries at a well known stable location. In the repo release would be great, or something like the k8s release notes binaries section. Forcing users to build the tool is a bit of a complexity leak.
go gethandled this more or less transparently, until it didn’t.@fertobar I might be wrong but I think that’s a grpc-gateway issue. Almost certainly the same problem as here though, you’ve got one version of your generator and another version of the runtime library. Please make sure you’re using the same version of both.
I have solve the problem ! I think its because the protoc-gen-go’s version not correct.
git clone https://github.com/golang/protobuf cd ~/protobuf/protoc-gen-go git chectout tags/v1.2.0 -b v1.2.0 go install
my environment is mac go1.11
I appreciate all the work you are doing, but I want to note that I find it highly disruptive to have released a breaking change on master without a new version.
go get -udoes not support versioning so it’s cumbersome to require a specific version. It also happens to not be currently possible with an internal solution we have to manage such. I know we could add support, but it goes to show that this is a cumbersome breaking change.I would recommend releasing a new version asap.
In the mean time, we have changed our projects to track the master branch, but this is not ideal either because in some other cases, the generator is installed in a docker image, so it is not always up-to-date.
Side note: Major version bump would probably be appropriate here. This is not a change where some people may be affected, it’s a hard version requirement, which completely breaks BC.
Personally, I find this change super disturbing but I understand that’s sometimes needed. I can’t find a way to make dep happy with
grpc-ecosystem/grpc-gatewaywith this new change. Has anybody tried it ?Errr, sorry, I mispoke. It’s not the
-Iflag. It’s the how the proto file to compile was specified when given toprotoc.For example:
Notice that all three have different values?
This behavior is surprising, but is an artifact of how protobufs were originally designed. That is, they assume a single root where all source files universally lived under in a build system similar to Bazel. It’s not great for today’s world of independently distributed build processes, but such is the status quo.
steps by @lenvs fixed the
ProtoPackageIsVersion3issue, but I’m gettingundefined: utilities.IOReaderFactorywith grpc after switch to v1.2.0 . any help is appreciated@DarrienG, how do you propose this be addressed? A major version bump is not the right answer:
We are cognizant of people’s setup within reason. I want to note that this change:
protopackage andprotoc-gen-go. I personally think people who do this are risky, but we try hard not to break this situation, and 8d0c54c1246661d9a51ca0ba455d22116d485eaa upheld this expectation as it atomically changed bothprotoandprotoc-gen-go.protopackage andprotoc-gen-go. This is my recommended approach for a healthy CI system.protopackage and a HEAD version ofprotoc-gen-go. It’s unfortunate that this situation breaks, but there is fundamentally no way that this combination of dependencies remain break-free sinceprotoc-gen-godepends onproto.While I agree that a build system should be hermetic and all, I think it’s silly this broke on a minor version. I would expect breakages in a
X.minor.bugsrelease but not amajor.X.bugsrelease.Gopkg even assumes it is safe to do this, and if you don’t specify an
=VERSIONit would have auto-upgraded a number of setups that would have been broken even if people did specify1.2.0.I know this is open source and all, but please consider being cognizant of people’s setups.
I’m not sure what we can do on our end, this seems to be an issue really with the Go toolchain that there isn’t an easy way (or at least I don’t know of one) to build a binary at a specific revision.
For the time being, you can do something like this:
Be sure to have
$BIN_PATHbe the output path where the binary should end up.