Repository navigation
fix(workflow): guard nil intermediateMessage in chatflow suggest - #2743
Open
skyzhao1223 wants to merge 1 commit into
Open
skyzhao1223 wants to merge 1 commit into
skyzhao1223 wants to merge 1 commit into
Conversation
The WorkflowSuccess branch dereferenced intermediateMessage.Content when suggest mode was enabled, but intermediateMessage is only set when a DataMessage is received (needRegeneratedMessage path). A workflow that completes without emitting a DataMessage (e.g. an end-only workflow) panicked with a nil pointer dereference. Skip suggest generation when there is no intermediate message, consistent with the nil guards already present at the other access sites.
skyzhao1223
requested review from
N3kox,
fanlv,
hi-pender,
junwen-lee,
liuyunchao-1998,
lvxinyu-1117,
mrh997 and
shentongmartin
as code owners
August 26, 2026 02:04
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.
Fixes a nil pointer dereference in the chatflow success path.
Problem
In
application/workflow/chatflow.go, theWorkflowSuccessbranch dereferencesintermediateMessage.Contentwhen suggest mode is enabled:But
intermediateMessagestarts asniland is only assigned when aDataMessageis received (theneedRegeneratedMessagepath, around line 1106). A workflow that completes without emitting anyDataMessage(e.g. an end-only workflow, or one whose outputs are allStateMessages) reaches this line withintermediateMessage == nil→ nil pointer dereference panic.Every other access site in the same function (
:818,:931,:953) already guards withintermediateMessage != nil; this one was missed.Fix
Add
&& intermediateMessage != nilto the suggest-mode condition. When there is no intermediate message there is nothing to base suggestions on, so suggest generation is skipped (safe degradation) instead of panicking.