Skip to content
Open
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: 4 additions & 0 deletions service/history/chasm_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ func (e *ChasmEngine) getExecutionLease(
executionLease.GetReleaseFn()(nil)
err = staleReferenceErr
}
var notFound *serviceerror.NotFound
if errors.As(err, &notFound) {
err = serviceerror.NewNotFound("execution not found")
}

return shardContext, executionLease, err
}
25 changes: 25 additions & 0 deletions service/history/chasm_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,31 @@ func (s *chasmEngineSuite) TestReadComponent_Success() {
s.NoError(err)
}

// TestReadComponent_NotFound tests that ReadComponent returns an appropriate NotFound error message.
func (s *chasmEngineSuite) TestReadComponent_NotFound() {
s.mockExecutionManager.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).
Return(nil, serviceerror.NewNotFound("this error message will not be returned by ReadComponent")).Times(1)

err := s.engine.ReadComponent(
context.Background(),
chasm.NewComponentRef[*testComponent](
chasm.ExecutionKey{
NamespaceID: string(tests.NamespaceID),
BusinessID: "non-existent-execution",
RunID: "11111111-2222-3333-4444-555555555555",
},
),
func(ctx chasm.Context, component chasm.Component) error {
s.Fail("readFn should not be called")
return nil
},
)
s.Error(err)
var notFound *serviceerror.NotFound
s.ErrorAs(err, &notFound)
s.Equal("execution not found", notFound.Message)
}

func (s *chasmEngineSuite) buildPersistenceMutableState(
key chasm.ExecutionKey,
componentState proto.Message,
Expand Down
Loading