fix(workflow): prevent nil pointer dereference when merging batch inner node executions#2715
Open
nankingjing wants to merge 2 commits into
Open
fix(workflow): prevent nil pointer dereference when merging batch inner node executions#2715nankingjing wants to merge 2 commits into
nankingjing wants to merge 2 commits into
Conversation
…er node executions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
fix
What this PR does / why we need it
mergeCompositeInnerNodes(inbackend/domain/workflow/service/executable_impl.go)builds its result by iterating the
nodeExesmap to seed agroupNodeExepointer, then unconditionally writes to it:
When
nodeExesis empty,groupNodeExestaysniland the subsequent writepanics with a nil pointer dereference.
This path is reachable from
GetNodeExecution. When a node running in batchmode (e.g. an LLM node with batch enabled, which is compiled into a
NodeTypeBatchparent + a generated<id>_innernode) is node-debugged, thefunction queries the inner executions via
GetNodeExecutionByParent. If thatreturns an empty slice — for example the batch iterated over an empty input
list, or the inner executions have not been persisted yet — the loop that
checks
IsGeneratedNodeForBatchModedoes not run,index2Exeis left empty,and
mergeCompositeInnerNodes(index2Exe, 0)is called with an empty map,triggering the panic in the request goroutine.
The fix returns early (
nil) when there are no inner executions to merge.GetNodeExecutionthen returns(nodeExe, nil, nil), which is consistent withthe other early-return branches of the function (a
nilinner execution isalready an expected value for callers such as
GetLatestNodeDebugInput). Theother caller,
GetExecution, only ever passes non-empty maps, so its behavioris unchanged.
Which issue(s) this PR fixes
Related to #2684 (behavior of
GetNodeExecutionfor batch / batch-mode nodes).Test plan
Adds
TestImpl_GetNodeExecutioncovering:The tests follow the existing table-driven
gomockstyle inexecutable_impl_test.go.Note: verified by reading types/signatures and tracing the code paths; the Go
build and tests were not executed in my environment.