Skip to content
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

Errors on valid timestamps #4973

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion runtime/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,11 @@ func parseMessage(msgDescriptor protoreflect.MessageDescriptor, value string) (p
if err != nil {
return protoreflect.Value{}, err
}
msg = timestamppb.New(t)
timestamp := timestamppb.New(t)
if ok := timestamp.IsValid(); !ok {
johanbrandhorst marked this conversation as resolved.
Show resolved Hide resolved
return protoreflect.Value{}, fmt.Errorf("%s before 0001-01-01", value)
}
msg = timestamp
case "google.protobuf.Duration":
d, err := time.ParseDuration(value)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions runtime/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ func TestPopulateParameters(t *testing.T) {
want: &examplepb.Proto3Message{},
wanterr: errors.New("invalid path: \"repeated_message\" is not a message"),
},
{
values: url.Values{
"timestampValue": {"0000-01-01T00:00:00.00Z"},
},
filter: utilities.NewDoubleArray(nil),
want: &examplepb.Proto3Message{},
wanterr: errors.New(`parsing field "timestamp_value": 0000-01-01T00:00:00.00Z before 0001-01-01`),
},
} {
t.Run(strconv.Itoa(i), func(t *testing.T) {
msg := spec.want.ProtoReflect().New().Interface()
Expand Down
Loading