Skip to content

fix: guard against empty choices and message=None in deployment checks#404

Open
qizwiz wants to merge 1 commit into
zai-org:mainfrom
qizwiz:fix/guard-unguarded-llm-choices
Open

fix: guard against empty choices and message=None in deployment checks#404
qizwiz wants to merge 1 commit into
zai-org:mainfrom
qizwiz:fix/guard-unguarded-llm-choices

Conversation

@qizwiz
Copy link
Copy Markdown

@qizwiz qizwiz commented May 18, 2026

Problem

Both scripts/check_deployment_cn.py and scripts/check_deployment_en.py print response.choices[0].message.content without checking if choices is empty or message is None.

This causes IndexError or AttributeError instead of a meaningful error during deployment validation.

Fix

Adds the guard before each access:

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

4 lines added, 0 deleted.

Detected by pact static analysis.

… scripts

response.choices[0].message.content raises IndexError (empty choices) or
AttributeError (message=None on filtered content) in both check_deployment
scripts, causing misleading crash output during deployment validation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant