From ab0b7feb4b15ef4ef0d4ccf90e5eeb5a52f4bc0c Mon Sep 17 00:00:00 2001 From: paxiaatucsdedu Date: Wed, 10 Dec 2025 15:01:43 -0800 Subject: [PATCH] Fix NullPointerException for empty message content Adds a check for empty message content before processing in GenericProvider, returning a default text when content is missing. --- libs/oci/langchain_oci/chat_models/oci_generative_ai.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/oci/langchain_oci/chat_models/oci_generative_ai.py b/libs/oci/langchain_oci/chat_models/oci_generative_ai.py index 30ea719..154fc57 100644 --- a/libs/oci/langchain_oci/chat_models/oci_generative_ai.py +++ b/libs/oci/langchain_oci/chat_models/oci_generative_ai.py @@ -815,7 +815,12 @@ def messages_to_oci_params( message.tool_calls or message.additional_kwargs.get("tool_calls") ): # Process content and tool calls for assistant messages - content = self._process_message_content(message.content) + if message.content: + content = self._process_message_content(message.content) + # Issue 78 fix: Check if original content is empty BEFORE processing + # to prevent NullPointerException in OCI backend + else: + content = [self.oci_chat_message_text_content(text=".")] tool_calls = [] for tool_call in message.tool_calls: tool_calls.append(