fullstorydev / fullstorydev/grpcurl

cannot unmarshal object google.protobuf.Timestamp

Open
#533 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
12.8k
Forks
580
Avg merge
1h 8m
Merged PRs (30d)
5

Description

```
% grpcurl -version
grpcurl 1.9.3
```
```
syntax = "proto3";

package demo;

option go_package = "./demo;demo";

import "google/protobuf/timestamp.proto";

service Demo {
rpc Test (TestRequest) returns (TestResponse);
}

message TestRequest {
google.protobuf.Timestamp date_of_birth = 1;
string name = 2;
}

message TestResponse {
string result = 1;
}
```
simple go-grpc server
```
package main

import (
"context"
"fmt"
"log"
"net"

"test/demo"

"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)

type server struct {
demo.UnimplementedDemoServer
}

func (s *server) Test(ctx context.Context, req *demo.TestRequest) (*demo.TestResponse, error) {
dob := "nil"
if req.DateOfBirth != nil {
dob = req.DateOfBirth.AsTime().String()
}
return &demo.TestResponse{
Result: fmt.Sprintf("Hello, %s! Date of birth: %s", req.Name, dob),
}, nil
}

func main() {
lis, err := net.Listen("tcp", ":8082")
if err != nil {
log.Fatalf("listen: %v", err)
}
grpcServer := grpc.NewServer()
demo.RegisterDemoServer(grpcServer, &server{})
reflection.Register(grpcServer)
fmt.Println("gRPC listening on :8082")
if err := grpcServer.Serve(lis); err != nil {
log.Fatalf("serve: %v", err)
}
}

```

```
% protoc --version
libprotoc 32.1

% grpcurl -plaintext -d '{"name":"Ivan", "date_of_birth": {"seconds": 820454400, "nanos": 0}}' localhost:8082 demo.Demo/Test
Error invoking method "demo.Demo/Test": error getting request data: json: cannot unmarshal object into Go value of type string

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the failure with the supplied demo proto, Go server, and grpcurl command against demo.Demo/Test. Compare the documented google.protobuf.Timestamp input with the failing object form; done means the request is accepted and the RPC receives the timestamp without the JSON unmarshalling error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.