[PR #817] [CLOSED] fix: guard against empty choices and message=None in DeepSeek response #14792

Closed
opened 2026-07-12 22:38:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Shubhamsaboo/awesome-llm-apps/pull/817
Author: @qizwiz
Created: 5/17/2026
Status: Closed

Base: mainHead: fix/guard-unguarded-llm-choices


📝 Commits (1)

  • cd34184 fix: guard against empty choices and message=None in DeepSeek response

📊 Changes

1 file changed (+2 additions, -0 deletions)

View changed files

📝 advanced_ai_agents/autonomous_game_playing_agent_apps/ai_3dpygame_r1/ai_3dpygame_r1.py (+2 -0)

📄 Description

Problem

In ai_3dpygame_r1.py, the DeepSeek API response is accessed without checking if choices is empty or message is None:

reasoning_content = deepseek_response.choices[0].message.reasoning_content

This crashes with:

  • IndexError when choices is [] (API returns no completions)
  • AttributeError when choices[0].message is None (filtered/refused content)

Fix

if not deepseek_response.choices or deepseek_response.choices[0].message is None:
    raise ValueError("LLM returned empty or filtered response")
reasoning_content = deepseek_response.choices[0].message.reasoning_content

2 lines added, 0 deleted.

Verification

Detected by pact static analysis (llm_response_unguarded rule). Confirmed: Gemini 2.5 Flash returns HTTP 200 with choices[0].message=None on prohibited content.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Shubhamsaboo/awesome-llm-apps/pull/817 **Author:** [@qizwiz](https://github.com/qizwiz) **Created:** 5/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/guard-unguarded-llm-choices` --- ### 📝 Commits (1) - [`cd34184`](https://github.com/Shubhamsaboo/awesome-llm-apps/commit/cd34184617dd17e5ae88ad6c84debab58fdc8ecc) fix: guard against empty choices and message=None in DeepSeek response ### 📊 Changes **1 file changed** (+2 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `advanced_ai_agents/autonomous_game_playing_agent_apps/ai_3dpygame_r1/ai_3dpygame_r1.py` (+2 -0) </details> ### 📄 Description ## Problem In `ai_3dpygame_r1.py`, the DeepSeek API response is accessed without checking if `choices` is empty or `message` is `None`: ```python reasoning_content = deepseek_response.choices[0].message.reasoning_content ``` This crashes with: - `IndexError` when `choices` is `[]` (API returns no completions) - `AttributeError` when `choices[0].message` is `None` (filtered/refused content) ## Fix ```python if not deepseek_response.choices or deepseek_response.choices[0].message is None: raise ValueError("LLM returned empty or filtered response") reasoning_content = deepseek_response.choices[0].message.reasoning_content ``` **2 lines added, 0 deleted.** ## Verification Detected by [pact](https://github.com/qizwiz/pact) static analysis (`llm_response_unguarded` rule). Confirmed: Gemini 2.5 Flash returns HTTP 200 with `choices[0].message=None` on prohibited content. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-07-12 22:38:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-llm-apps#14792