Skip to content

Commit df5012a

Browse files
committed
LCORE-464: fix potential None reference handling
1 parent 6182cd7 commit df5012a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/app/endpoints/query.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,11 @@ async def retrieve_response( # pylint: disable=too-many-locals
492492
# Metric for LLM validation errors
493493
metrics.llm_calls_validation_errors_total.inc()
494494
break
495+
if response is not None and response.output_message is not None: # type: ignore[union-attr]
496+
return str(response.output_message.content), conversation_id # type: ignore[union-attr]
495497

496-
return str(response.output_message.content), conversation_id # type: ignore[union-attr]
498+
logger.warning("Response does not contain any message to be returned")
499+
return "", conversation_id # fallback
497500

498501

499502
def validate_attachments_metadata(attachments: list[Attachment]) -> None:

0 commit comments

Comments
 (0)