Skip to content

fix: NPE in streaming chat-completions function chain #1963 - #1964

Merged
astsiapanay merged 1 commit into
developmentfrom
fix/issue-1963
Sep 11, 2026
Merged

fix: NPE in streaming chat-completions function chain #1963#1964
astsiapanay merged 1 commit into
developmentfrom
fix/issue-1963

Conversation

@astsiapanay

Copy link
Copy Markdown
Collaborator

Fixes a null-pointer exception in the streaming /chat/completions response-function chain that silently fires on nearly every streaming chunk with no attachments, logged as "Function call is failed with error. Try to recover SSE event" and swallowed by generic error recovery.

Applicable issues

Description of changes

  • CollectResponseAttachmentsFn.apply() now returns Future.succeededFuture(tree) instead of a null-valued future when a chunk has no attachments, so the tree is passed through unchanged instead of dropped.
  • CollectChatCompletionUsageFn.apply() now guards against a null tree input, preventing a similar mistake elsewhere in the chain from causing the same regression.
  • BufferingReadStream.BaseEventListener.handle() now guards against a null/blank SSE data payload before parsing it as JSON.
  • Added a regression test (CollectResponseChatCompletionAttachmentsFnTest#testApplyPassesTreeThroughUnchangedWhenNoAttachments) and a null-tolerance test (CollectChatCompletionUsageFnTest#testTolerantOfNullTree), plus a new ChatCompletionFunctionChainTest that exercises the real 3-function chain used by DeploymentPostController end-to-end, closing the test gap that let this regression through originally (each function was previously only tested in isolation).

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ai-dial-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@astsiapanay
astsiapanay merged commit 7d7fe58 into development Sep 11, 2026
10 checks passed
@astsiapanay
astsiapanay deleted the fix/issue-1963 branch September 11, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in streaming chat-completions function chain: "Function call is failed with error. Try to recover SSE event"

3 participants