Problem with timestamp data format while migrating to protoc4 from protoc 3.6.1

43 views
Skip to first unread message

rajegun

unread,
Aug 8, 2020, 6:31:14 AM8/8/20
to Protocol Buffers
Hello there,

We are currently using protoc 3.6.1 and planning to migrate to 4.x

During our POC on this migration we found timestamp returned using our existing code has differed from the format we were using, digging further we dont know what exactly caused the problem.

Timeformat received with 3.6.1 => "time": "2020-07-31T07:13:07.396733914Z",

Timeformat received with 4.0.0 => "time": {
    "seconds": "1596871176",
    "nanos": 363018229
  },

Code:

partner.proto
------------------------------------------------
message ResponsePartnerEmployeeList {
    ......
    google.protobuf.Timestamp time = 3;
}

partner.pg.go file (protoc 3.6.1 version created)
-----------------------------------------------

type ResponseList struct {
    .....
    Time                 *timestamp.Timestamp     `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"`

    XXX_NoUnkeyedLiteral struct{}                 `json:"-"`
    XXX_unrecognized     []byte                   `json:"-"`
    XXX_sizecache        int32                    `json:"-"`
}

partner.pg.go file (protoc 4.0.0 version created)
-----------------------------------------------

type ResponseList struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    .......
    Time *timestamp.Timestamp `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"`
}
-----------------------------------------------

utils.go file (time data is updated here to the structure)


func GenerateResponse(errorCode Error, mesg ...string) *pb.ResponseList {
time, _ := ptypes.TimestampProto(time.Now())

    return &pb.ResponseList{
        ....
        ....
        ....
        Time: time,
    }

---------------------

Problem in the time format received, this affects our application which expects the data in 3.6.1 format

Timeformat received with 3.6.1 => "time": "2020-07-31T07:13:07.396733914Z",

Timeformat received with 4.0.0 => "time": {
    "seconds": "1596871176",
    "nanos": 363018229
  },

Adam Cozzette

unread,
Aug 11, 2020, 6:20:15 PM8/11/20
to rajegun, Protocol Buffers
That problem is a little bit surprising because the Go code generator is implemented as a plugin in a separate repo, and shouldn't therefore be affected by a protoc upgrade. Did you upgrade your Go protoc plugin at the same time?

As a side note, sorry for the confusion but we decided not to increment the major version from 3 to 4 yet. We published artifacts for 4.0.0-rc1 and 4.0.0-rc2 but there will not be a 4.0 release in the immediate future. We are going to release 3.13.0 soon instead.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/3a10f37f-0fee-48c8-bced-05d45af4a5b9o%40googlegroups.com.

rajegun

unread,
Aug 18, 2020, 10:11:00 AM8/18/20
to Protocol Buffers
Thanks for the update and the notes about the version upgrade, we were thinking of doing upgrade but we will probably stick to 3.13.0 instead as you had mentioned.
We have now fixed the issue by rolling back to older version of the libraries and the dependencies we had in the ubuntu 18.04 environment.

Reply all
Reply to author
Forward
0 new messages