fix(sticky): checking get workflow history when sticky decision task#631
fix(sticky): checking get workflow history when sticky decision task#631yux0 wants to merge 1 commit intocadence-workflow:masterfrom
Conversation
| .setExecution(decisionTask.getWorkflowExecution()); | ||
| GetWorkflowExecutionHistoryResponse getHistoryResponse = | ||
| service.GetWorkflowExecutionHistory(getHistoryRequest); | ||
| if (getHistoryResponse.getHistory().getEventsSize() == 0) { |
There was a problem hiding this comment.
⚠️ Bug: Potential NPE on getHistoryResponse.getHistory() not guarded
The new check calls getHistoryResponse.getHistory().getEventsSize() but does not guard against getHistory() itself returning null. The original NPE described in the PR was on a similar chain (decisionTask.getHistory().getEvents().get(0)...). If the server returns a response with a null History field, this new code will throw an NPE instead of the intended RuntimeException.
Additionally, the same null risk exists on line 268 (decisionTask.getHistory().getEvents()) before the sticky check — if decisionTask.getHistory() is null, the method crashes before ever reaching the new guard. This is pre-existing, but worth noting since the PR aims to harden this path.
Suggested fix:
if (getHistoryResponse == null
|| getHistoryResponse.getHistory() == null
|| getHistoryResponse.getHistory().getEventsSize() == 0) {
throw new RuntimeException("Failed to get workflow execution history for replay");
}
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
We see NPE in ReplayDecider with line: decisionTask.getHistory().getEvents().get(0).getWorkflowExecutionStartedEventAttributes();
In ReplayDecisionTaskHandler, we have special handling for sticky decision task that has a partial history. But we do not check the returned history. So add a check to get workflow history when sticky decision task