-
Notifications
You must be signed in to change notification settings - Fork 53
Fix NullReferenceException when history contains entity events #617
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
base: main
Are you sure you want to change the base?
Conversation
… conversions Co-authored-by: YunchuWang <[email protected]>
…tent naming Co-authored-by: YunchuWang <[email protected]>
| this.sidecarClient.StreamInstanceHistory(streamRequest, cancellationToken: cancellation); | ||
|
|
||
| Microsoft.DurableTask.ProtoUtils.EntityConversionState? entityConversionState = | ||
| this.options.EnableEntitySupport |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has nothing to do with enableentitysupport, remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 99ee0e7. EntityConversionState is now always created regardless of EnableEntitySupport since history may contain entity events even if the client option is disabled.
|
|
||
| Microsoft.DurableTask.ProtoUtils.EntityConversionState? entityConversionState = | ||
| this.options.EnableEntitySupport | ||
| ? new(insertMissingEntityUnlocks: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without orchestration instanceid, it will throw missing parent instance id exception later i think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The orchestration instance ID is automatically set when the ExecutionStarted event is processed during history conversion (see ProtoUtils.cs line 62: conversionState?.SetOrchestrationInstance(instance)). No manual setting is needed.
|
|
||
| List<HistoryEvent> pastEvents = request.PastEvents.Select(ProtoUtils.ConvertHistoryEvent).ToList(); | ||
| IEnumerable<HistoryEvent> newEvents = request.NewEvents.Select(ProtoUtils.ConvertHistoryEvent); | ||
| ProtoUtils.EntityConversionState entityConversionState = new(insertMissingEntityUnlocks: false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont we need instanceid specified here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The orchestration instance ID is automatically set when the ExecutionStarted event is processed during history conversion (see ProtoUtils.cs line 62: conversionState?.SetOrchestrationInstance(instance)). No manual setting is needed.
YunchuWang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot address
…State The EntityConversionState should always be created regardless of the EnableEntitySupport option because: 1. History may contain entity events even if the client option is disabled 2. The orchestration instance ID is automatically set when ExecutionStarted event is processed 3. This matches the pattern used in GrpcDurableTaskWorker.Processor Co-authored-by: YunchuWang <[email protected]>
Summary: Fix NullReferenceException in Entity Event Conversion
Problem
When orchestration history contains entity events (such as
EntityOperationCalled,EntityLockRequested,EntityUnlockSent, etc.), the streaming or get history APIs throw aNullReferenceException.Root Cause
GetOrchestrationHistoryAsyncinGrpcDurableTaskClient.csandLoadAndRuninGrpcOrchestrationRunner.cscalledProtoUtils.ConvertHistoryEventwithout passing anEntityConversionStateProtoUtils.cs, entity event handlers useconversionState!.CurrentInstancewith the null-forgiving operator, causing runtime exceptions whenconversionStateis nullSolution
Updated both methods to always create and use
EntityConversionStatewhen converting history events:GrpcDurableTaskClient.GetOrchestrationHistoryAsyncEntityConversionState(not conditional on EnableEntitySupport)GrpcOrchestrationRunner.LoadAndRunEntityConversionStatefor entity event conversionImplementation Details
GrpcDurableTaskWorker.Processor.BuildRuntimeStateAsyncinsertMissingEntityUnlocks: falsefor read-only operationsTesting
Files Changed
src/Client/Grpc/GrpcDurableTaskClient.cssrc/Worker/Grpc/GrpcOrchestrationRunner.csOriginal prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.