mirror of
https://github.com/Shubhamsaboo/awesome-llm-apps.git
synced 2026-07-17 08:22:34 -05:00
[GH-ISSUE #839] bug: unguarded OpenAI API response access crashes beifong news/podcast agent #12684
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?
Originally created by @zavoryn on GitHub (May 25, 2026).
Original GitHub issue: https://github.com/Shubhamsaboo/awesome-llm-apps/issues/839
Bug Description
Three files in the
beifongnews/podcast multi-agent app accessresponse.choices[0].message.contentwithout first checking thatchoicesis non-empty andcontentis notNone.This can cause:
IndexErrorwhen the API returns an emptychoiceslist (e.g. content filter triggered, quota exceeded, or transient API error)TypeErrorwhenjson.loads()receivesNoneinstead of a stringAffected Files
processors/ai_analysis_processor.pyjson.loads(response.choices[0].message.content)utils/translate_podcast.pyresponse.choices[0].message.contentutils/get_articles.pyjson.loads(resp.choices[0].message.content.strip())Expected Behavior
The code should guard against an empty or null API response before accessing
choices[0], similar to the fix applied in PR #820 for the DeepSeek API calls.Fix
Add a guard before each access:
I have a PR ready with the fix applied to all three files.
@carter-smalls commented on GitHub (May 25, 2026):
Seems like rate-limit trouble with OpenAI. A quick
npx ai-doctorrun can flag missing Retry-After handling and unsafe retry logic.@markseibal-png commented on GitHub (May 25, 2026):
Looks like a rate-limit problem on OpenAI.
npx ai-doctorcan surface missing Retry-After handling and unsafe retry logic.@Shubhamsaboo commented on GitHub (Jun 2, 2026):
Thanks for flagging this. The proposed fix in #840 was reviewed and closed without merging, so we're closing this issue to match. In
get_articles.pythe call is already wrapped in atry/exceptthat falls back to[prompt.strip()], so an empty/Noneresponse is handled there rather than crashing. We're not planning to add the extra guards across the beifong utilities right now. If it shows up as a real crash in practice, we can revisit.Generated by Claude Code