Skip to content

Commit

Permalink
jsonpb: fix a confusing error message (#1125)
Browse files Browse the repository at this point in the history
The in argument is a []byte. Using the %v print flag prints this list of integers
instead of as a string representation of the enum value. Use %q instead.
  • Loading branch information
ijschwabacher authored May 11, 2020
1 parent 6c66de7 commit 00998c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jsonpb/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (u *Unmarshaler) unmarshalSingularValue(v protoreflect.Value, in []byte, fd
if hasPrefixAndSuffix('"', in, '"') {
vd := fd.Enum().Values().ByName(protoreflect.Name(trimQuote(in)))
if vd == nil {
return v, fmt.Errorf("unknown value %v for enum %s", in, fd.Enum().FullName())
return v, fmt.Errorf("unknown value %q for enum %s", in, fd.Enum().FullName())
}
return protoreflect.ValueOfEnum(vd.Number()), nil
}
Expand Down

0 comments on commit 00998c7

Please sign in to comment.