Skip to content

Commit 5f35b19

Browse files
committed
Fix CHASM not found errors
1 parent 2e7b2c7 commit 5f35b19

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

service/history/chasm_engine.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,10 @@ func (e *ChasmEngine) getExecutionLease(
621621
executionLease.GetReleaseFn()(nil)
622622
err = staleReferenceErr
623623
}
624+
var notFound *serviceerror.NotFound
625+
if errors.As(err, &notFound) {
626+
err = serviceerror.NewNotFoundf("execution not found")
627+
}
624628

625629
return shardContext, executionLease, err
626630
}

service/history/chasm_engine_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,31 @@ func (s *chasmEngineSuite) TestReadComponent_Success() {
625625
s.NoError(err)
626626
}
627627

628+
// TestReadComponent_NotFound tests that ReadComponent returns an appropriate NotFound error message.
629+
func (s *chasmEngineSuite) TestReadComponent_NotFound() {
630+
s.mockExecutionManager.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).
631+
Return(nil, serviceerror.NewNotFound("this error message will not be returned by ReadComponent")).Times(1)
632+
633+
err := s.engine.ReadComponent(
634+
context.Background(),
635+
chasm.NewComponentRef[*testComponent](
636+
chasm.ExecutionKey{
637+
NamespaceID: string(tests.NamespaceID),
638+
BusinessID: "non-existent-execution",
639+
RunID: "11111111-2222-3333-4444-555555555555",
640+
},
641+
),
642+
func(ctx chasm.Context, component chasm.Component) error {
643+
s.Fail("readFn should not be called")
644+
return nil
645+
},
646+
)
647+
s.Error(err)
648+
var notFound *serviceerror.NotFound
649+
s.ErrorAs(err, &notFound)
650+
s.Equal("execution not found", notFound.Message)
651+
}
652+
628653
func (s *chasmEngineSuite) buildPersistenceMutableState(
629654
key chasm.ExecutionKey,
630655
componentState proto.Message,

0 commit comments

Comments
 (0)