10000 Change operator service error codes if Search attributes are not found or already exist by Spikhalskiy · Pull Request #2627 · temporalio/temporal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Change operator service error codes if Search attributes are not found or already exist #2627

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

Merged
merged 1 commit into from
Mar 21, 2022
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
4 changes: 2 additions & 2 deletions service/frontend/operator_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (h *OperatorHandlerImpl) AddSearchAttributes(ctx context.Context, request *
return nil, h.error(serviceerror.NewInvalidArgument(fmt.Sprintf(errSearchAttributeIsReservedMessage, saName)), scope, endpointName)
}
if currentSearchAttributes.IsDefined(saName) {
return nil, h.error(serviceerror.NewInvalidArgument(fmt.Sprintf(errSearchAttributeAlreadyExistsMessage, saName)), scope, endpointName)
return nil, h.error(serviceerror.NewAlreadyExist(fmt.Sprintf(errSearchAttributeAlreadyExistsMessage, saName)), scope, endpointName)
}
if _, ok := enumspb.IndexedValueType_name[int32(saType)]; !ok {
return nil, h.error(serviceerror.NewInvalidArgument(fmt.Sprintf(errUnknownSearchAttributeTypeMessage, saType)), scope, endpointName)
Expand Down Expand Up @@ -221,7 +221,7 @@ func (h *OperatorHandlerImpl) RemoveSearchAttributes(ctx context.Context, reques

for _, saName := range request.GetSearchAttributes() {
if !currentSearchAttributes.IsDefined(saName) {
return nil, h.error(serviceerror.NewInvalidArgument(fmt.Sprintf(errSearchAttributeDoesntExistMessage, saName)), scope, endpointName)
return nil, h.error(serviceerror.NewNotFound(fmt.Sprintf(errSearchAttributeDoesntExistMessage, saName)), scope, endpointName)
}
if _, ok := newCustomSearchAttributes[saName]; !ok {
return nil, h.error(serviceerror.NewInvalidArgument(fmt.Sprintf(errUnableToRemoveNonCustomSearchAttributesMessage, saName)), scope, endpointName)
Expand Down
8 changes: 4 additions & 4 deletions service/frontend/operator_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributes() {
"CustomTextField": enumspb.INDEXED_VALUE_TYPE_TEXT,
},
},
Expected: &serviceerror.InvalidArgument{Message: "Search attribute CustomTextField already exists."},
Expected: &serviceerror.AlreadyExists{Message: "Search attribute CustomTextField already exists."},
},
}
for _, testCase := range testCases3 {
Expand Down Expand Up @@ -174,7 +174,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributes() {
"CustomTextField": enumspb.INDEXED_VALUE_TYPE_TEXT,
},
},
Expected: &serviceerror.InvalidArgument{Message: "Search attribute CustomTextField already exists."},
Expected: &serviceerror.AlreadyExists{Message: "Search attribute CustomTextField already exists."},
},
}
for _, testCase := range testCases2 {
Expand Down Expand Up @@ -315,7 +315,7 @@ func (s *operatorHandlerSuite) Test_RemoveSearchAttributes() {
"ProductId",
},
},
Expected: &serviceerror.InvalidArgument{Message: "Search attribute ProductId doesn't exist."},
Expected: &serviceerror.NotFound{Message: "Search attribute ProductId doesn't exist."},
},
}
for _, testCase := range testCases3 {
Expand Down Expand Up @@ -351,7 +351,7 @@ func (s *operatorHandlerSuite) Test_RemoveSearchAttributes() {
"ProductId",
},
},
Expected: &serviceerror.InvalidArgument{Message: "Search attribute ProductId doesn't exist."},
Expected: &serviceerror.NotFound{Message: "Search attribute ProductId doesn't exist."},
},
}
for _, testCase := range testCases2 {
Expand Down
0