fix: NPE in streaming chat-completions function chain #1963 - #1964
Merged
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Oleksii-Klimov
approved these changes
Sep 11, 2026
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 null-pointer exception in the streaming
/chat/completionsresponse-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 returnsFuture.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 nulltreeinput, preventing a similar mistake elsewhere in the chain from causing the same regression.BufferingReadStream.BaseEventListener.handle()now guards against a null/blank SSEdatapayload before parsing it as JSON.CollectResponseChatCompletionAttachmentsFnTest#testApplyPassesTreeThroughUnchangedWhenNoAttachments) and a null-tolerance test (CollectChatCompletionUsageFnTest#testTolerantOfNullTree), plus a newChatCompletionFunctionChainTestthat exercises the real 3-function chain used byDeploymentPostControllerend-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.