From 1e191789e37069157e204ad3d72db33e4da9fa71 Mon Sep 17 00:00:00 2001 From: Liang Mei Date: Thu, 20 Jan 2022 23:37:04 -0800 Subject: [PATCH] Add validation for invalid starttime filter for standard visibility (#2401) --- .../persistence/visibility/store/standard/converter_test.go | 1 + .../visibility/store/standard/query_interceptors.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/common/persistence/visibility/store/standard/converter_test.go b/common/persistence/visibility/store/standard/converter_test.go index fcd4f4d572f..c30dc159e4d 100644 --- a/common/persistence/visibility/store/standard/converter_test.go +++ b/common/persistence/visibility/store/standard/converter_test.go @@ -61,6 +61,7 @@ var unsupportedQuery = []string{ `ExecutionStatus = "Running" AND WorkflowType = "xyz"`, `WorkflowID = "abc" OR WorkflowType = "xyz"`, `WorkflowID != "abc"`, + `StartTime < "2022-01-15T05:43:12.74127Z"`, } func TestSupportedQueryFilters(t *testing.T) { diff --git a/common/persistence/visibility/store/standard/query_interceptors.go b/common/persistence/visibility/store/standard/query_interceptors.go index 540cb717821..8d9a42193f9 100644 --- a/common/persistence/visibility/store/standard/query_interceptors.go +++ b/common/persistence/visibility/store/standard/query_interceptors.go @@ -98,6 +98,10 @@ func (vi *valuesInterceptor) Values(name string, values ...interface{}) ([]inter } return values, err case searchattribute.StartTime: + if len(values) != 2 { + return nil, query.NewConverterError("StartTime only supports BETWEEN ... AND ... filter") + } + values, err := vi.nextInterceptor.Values(name, values...) if err == nil { minTime, err := time.Parse(time.RFC3339Nano, values[0].(string))