Skip to content

Commit

Permalink
Fix hand-crafted protobuf message (#1016)
Browse files Browse the repository at this point in the history
errorBody is an improperly hand-crafted protobuf Message.
In particular, field number 1 is used twice, causing this to
message to crash in the v2 re-implementation of Go protobufs.

This PR modifies the field numbers to be unique.
Since Error is a special field not in status.proto,
we choose a large field number to avoid conflicting with
any new field that may be added to the real Status message.
We also fix the field numbers to truly match up with Status.
  • Loading branch information
dsnet authored and achew22 committed Aug 30, 2019
1 parent a9bbe40 commit 2da5bfa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runtime/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ var (
)

type errorBody struct {
Error string `protobuf:"bytes,1,name=error" json:"error"`
Error string `protobuf:"bytes,100,name=error" json:"error"`
// This is to make the error more compatible with users that expect errors to be Status objects:
// https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto
// It should be the exact same message as the Error field.
Message string `protobuf:"bytes,1,name=message" json:"message"`
Code int32 `protobuf:"varint,2,name=code" json:"code"`
Code int32 `protobuf:"varint,1,name=code" json:"code"`
Message string `protobuf:"bytes,2,name=message" json:"message"`
Details []*any.Any `protobuf:"bytes,3,rep,name=details" json:"details,omitempty"`
}

Expand Down

0 comments on commit 2da5bfa

Please sign in to comment.