-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
protobuf/types/known/timestamppb not recognized by gRPC module #1579
Comments
I’m confused a lot by these examples. You seem to be using relative imports (which I have not used at all since we started using |
I have a repository where I define the The next There was a bit of clean up to post this, as well as the error being so strange (lost a few days to it pulling hairs) that it's hard to explain. But put in a sentence: Why is the protobuf auto generated |
Is this the complete and total output of the compilation error:
This message oddly suggest something is wrong with your |
I didn't catch anything odd with the import line there, but sure thing! evaluation_grpc.pb.go// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc (unknown)
// source: evaluation/v1/evaluation.proto
package v1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7 evaluation.pb.go// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc (unknown)
// source: evaluation/v1/evaluation.proto
package v1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) |
And can you confirm that this was the full output of compilation error? |
Yes. In my personal project running
With no other errors |
Hm… this is just so confusing. I’m wondering if it’s possible for you to create a minimal repro, which we would be able to check out and poke around with? |
Sorry for the long delay. Needed some approval to upload things and had to clean the repo, and since then got quite sick for a bit. That time of year. I also worried this was an internal proxy issue and was wasting your time, but I cannot explain how that could be part of it anymore after another two weeks of wrangling with this. Here's a link to a cleaned up repo of the feature flag system I'm building. Below is a simplified proto file that creates the same issue evaluation.protosyntax = "proto3";
package evaluation.v1;
import "google/protobuf/timestamp.proto";
option go_package = "flag-management-system/evaluation/v1";
service FlagManagementSystemService {
rpc BoolEvaluation(BoolEvaluationRequest) returns (BoolEvaluationResponse) {}
}
// // // // // Base Response // // // // //
// Response status structure
message ResponseStatus {
bool success = 1;
ErrorMessage error = 2;
}
// Error message structure
message ErrorMessage {
string code = 1;
string message = 2;
}
// // // // // Base Flag Evaluation // // // // //
// Extended evaluation request to include more types
message EvaluationRequest {
string flag_path = 1;
EvaluationContext context = 10; // Possible addition of evaluation context?
}
// Response structure for different types of feature flags
message EvaluationResponse {
string flag_path = 1;
ResponseStatus status = 5;
}
// // // // // Bool Flag Evaluation // // // // //
// Boolean flags request
message BoolEvaluationRequest {
uint32 batch_size = 1;
repeated EvaluationRequest requests = 10;
}
// Single Boolean flag response
message BoolSingleFlagResponse {
bool value = 1;
EvaluationResponse metadata = 5;
}
// Boolean flags response
message BoolEvaluationResponse {
uint32 response_size = 1;
repeated BoolSingleFlagResponse results = 10;
}
// // // // // Context Evaluation // // // // //
// Provider Context
message EvaluationContext {
// Provider-specific information
string provider_id = 1;
string provider_has = 2;
// Environmental and temporal data
google.protobuf.Timestamp request_time = 3;
string request_time_zone = 4;
string provider_language = 5;
string provider_version = 6;
} And the relevant part of the buf.gen.yamlversion: v1
plugins:
# Go
- plugin: buf.build/protocolbuffers/go
out: gen/go
opt:
- paths=source_relative
- plugin: buf.build/grpc/go
out: gen/go
opt:
- paths=source_relative
As said before, when this is generated with |
I checked out your repo, but I get an issue with Removing this line from the |
What version of protobuf and what language are you using?
Version:
google.golang.org/protobuf v1.31.0
What did you do?
I am trying to use a timestamppb type in my proto file, but even though the file exists
timestamppb.go
exists locally in the correct location, and I can import it in my own projects, my package (uploaded to a local artifactory storage solution then downloaded as a user) does not see thetimestamppb
module.evaluation.proto
The corresponding
go.mod
when runningbuf generate
and the building in go looks like:go.mod
Above is all in the repository where the protobuf contracts are defined, built, and deployed to Artifactory.
Next, I have a project that downloads from Artifactory the contract and uses it. It also has a
go.mod
that looks like:go.mod
main.go
This repo uses the contract to send flag data to a server. Above, I've imported timestamppb, and it builds fine and is able to use
timestamppb.Now()
without issue. The problem is the provider moduleprovider "subDirectory/provider"
uses theevaluation.pb.go
file from the protobuf contract, which in and of itself cannot resolvetimestamppb
for some reason. Theprovider.go
file looks as follows:provider.go
Here,
v1 "evaluation/evaluation/v1"
calls the generated proto files, where the following two lines exist at the start ofevaluation.pb.go
:evaluation.pb.go
protoimpl
imports without issue, buttimestamppb
fails, statingThis is in the
evaluation.pb.go
file, located at~go/pkg/mod/[email protected]/evaluation/v1/evaluation.pb.go
. It fails to findtimestamppb
located at:~/go/pkg/mod/google.golang.org/[email protected]/types/known/timestamppb/
, even though in my workspace directory where the project i (the abovemain.go
, the exact same import,timestamppb "google.golang.org/protobuf/types/known/timestamppb"
is used and correctly resolves the package.I've lost days to trying to understand where the issue is. Why does my project see
google.golang.org/protobuf/types/known/timestamppb
, but the protobuf generated file does not see it the same path?Anything else we should know about your project / environment?
Have two go envs that matter, since my project has set
GOPROXY
` go env` in my project
Yes, I had to change the proxy to collect from the local artifactory solution. The
go.env
in the protobuf file location (~go/pkg/mod/[email protected]/evaluation/v1/evaluation.pb.go
) on the other hand is:`go env` at protobuf repo
The text was updated successfully, but these errors were encountered: