mirror of
https://github.com/Shubhamsaboo/awesome-llm-apps.git
synced 2026-07-17 08:22:34 -05:00
[PR #840] [CLOSED] fix: guard against empty choices and None content in beifong OpenAI API responses #15448
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Shubhamsaboo/awesome-llm-apps/pull/840
Author: @zavoryn
Created: 5/25/2026
Status: ❌ Closed
Base:
main← Head:fix/guard-openai-choices-access-beifong📝 Commits (1)
49c683cfix: guard against empty choices and None content in beifong OpenAI API responses📊 Changes
3 files changed (+6 additions, -0 deletions)
View changed files
📝
advanced_ai_agents/multi_agent_apps/ai_news_and_podcast_agents/beifong/processors/ai_analysis_processor.py(+2 -0)📝
advanced_ai_agents/multi_agent_apps/ai_news_and_podcast_agents/beifong/utils/get_articles.py(+2 -0)📝
advanced_ai_agents/multi_agent_apps/ai_news_and_podcast_agents/beifong/utils/translate_podcast.py(+2 -0)📄 Description
Summary
Fixes #839
Three utilities in the
beifongnews/podcast multi-agent app accessedresponse.choices[0].message.contentwithout first verifying thatchoicesis non-empty andcontentis notNone. This mirrors the same class of bug fixed in PR #820 for DeepSeek API responses.Affected files:
processors/ai_analysis_processor.py— article analysis with GPT-4outils/translate_podcast.py— podcast translation with GPT-4outils/get_articles.py— search term extraction with GPT-4o-miniRoot cause: OpenAI can return an empty
choiceslist orNonecontent when a content filter is triggered, a quota is exceeded, or a transient API error occurs. Without a guard, this crashes withIndexErroror passesNonetojson.loads().Fix: Add an explicit guard before accessing
choices[0].message.contentin all three files, raising a descriptiveValueErrorthat propagates cleanly to the surroundingexceptblock already present in each function.Test plan
ValueErroris raised (and caught by the outerexcept Exception) whenchoicesis empty orcontentisNone🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.