Skip to content

Fix handling of empty choices and missing output in OpenAI API response#13

Merged
chakravarthik27 merged 1 commit into
mainfrom
fix-the-open-ai-client-when-model-response-is-empty
May 5, 2026
Merged

Fix handling of empty choices and missing output in OpenAI API response#13
chakravarthik27 merged 1 commit into
mainfrom
fix-the-open-ai-client-when-model-response-is-empty

Conversation

@chakravarthik27
Copy link
Copy Markdown

This pull request improves error handling for invalid or incomplete responses from the OpenAI API in both the openai_client.py and openai_responses_client.py modules. The main focus is to ensure that cases where expected fields are missing or null are caught early and handled gracefully, returning informative error results.

Enhanced error handling for API responses:

  • Added a check in openai_client.py to detect if the "choices" field is missing or None in the OpenAI API response, logging an exception and returning a structured error result if so.
  • Added a check in openai_responses_client.py to return an error result if the output field in the response is None, preventing downstream errors and providing a clear error message.

Copy link
Copy Markdown

@blidiselalin blidiselalin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go

@chakravarthik27 chakravarthik27 merged commit 0c9f90f into main May 5, 2026
6 checks passed
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.

3 participants