Skip to content

Commit

Permalink
Change Invalid search attribute value message (#2705)
Browse files Browse the repository at this point in the history
Rework the error message about invalid search attribute to the same pattern as our validation errors to remove the need to escape the original value in the final message
  • Loading branch information
Spikhalskiy authored Apr 6, 2022
1 parent c1d63b7 commit 659c052
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/searchattribute/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (v *Validator) Validate(searchAttributes *commonpb.SearchAttributes, namesp
if err = payload.Decode(saPayload, &invalidValue); err != nil {
invalidValue = fmt.Sprintf("value from <%s>", saPayload.String())
}
return serviceerror.NewInvalidArgument(fmt.Sprintf("%v is not a valid value for search attribute %s of type %s", invalidValue, saName, saType))
return serviceerror.NewInvalidArgument(fmt.Sprintf("invalid value for search attribute %s of type %s: %v", saName, saType, invalidValue))
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions common/searchattribute/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (s *searchAttributesValidatorSuite) TestSearchAttributesValidate() {
attr.IndexedFields = fields
err = saValidator.Validate(attr, namespace, "")
s.Error(err)
s.Equal("123 is not a valid value for search attribute CustomBoolField of type Bool", err.Error())
s.Equal("invalid value for search attribute CustomBoolField of type Bool: 123", err.Error())

intArrayPayload, err := payload.Encode([]int{1, 2})
s.NoError(err)
Expand Down Expand Up @@ -174,7 +174,7 @@ func (s *searchAttributesValidatorSuite) TestSearchAttributesValidate_Mapper() {
attr.IndexedFields = fields
err = saValidator.Validate(attr, namespace, "")
s.Error(err)
s.Equal("123 is not a valid value for search attribute alias_of_CustomBoolField of type Bool", err.Error())
s.Equal("invalid value for search attribute alias_of_CustomBoolField of type Bool: 123", err.Error())
}

func (s *searchAttributesValidatorSuite) TestSearchAttributesValidateSize() {
Expand Down

0 comments on commit 659c052

Please sign in to comment.