Skip to content

Commit 803132d

Browse files
committed
Fix CHASM not found errors
1 parent 2e7b2c7 commit 803132d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,32 @@ func (s *chasmEngineSuite) TestReadComponent_Success() {
625625
s.NoError(err)
626626
}
627627

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

0 commit comments

Comments
 (0)