Fix NullReferenceException when history contains entity events#617
Fix NullReferenceException when history contains entity events#617
Conversation
… conversions Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
…tent naming Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
| this.sidecarClient.StreamInstanceHistory(streamRequest, cancellationToken: cancellation); | ||
|
|
||
| Microsoft.DurableTask.ProtoUtils.EntityConversionState? entityConversionState = | ||
| this.options.EnableEntitySupport |
There was a problem hiding this comment.
this has nothing to do with enableentitysupport, remove it
There was a problem hiding this comment.
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.
without orchestration instanceid, it will throw missing parent instance id exception later i think
There was a problem hiding this comment.
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.
dont we need instanceid specified here?
There was a problem hiding this comment.
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.
…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 <12449837+YunchuWang@users.noreply.github.com>
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.