Skip to content

Commit ad893a2

Browse files
authored
fix: detect silent failures in gemini-cli by checking for invalid JSO… (#406)
I have updated the run-gemini-cli action to detect silent failures where the gemini CLI command produces no output (or invalid JSON) but exits with success (0). This typically happens when API resource limits are exceeded in non-interactive mode. Verification Results Automated Verification I created a reproduction script >_reproduce_issue.sh that tested two scenarios: 1. Success Case: gemini exits with 0, produces valid JSON stdout, and empty stderr. -> PASSED (Action succeeded) 2. Failure Case: gemini exits with 0, produces empty stdout, and empty stderr. -> PASSED (Action failed as expected) This confirms that the action now correctly catches the silent failure mode without introducing false positives for normal success cases where stderr is empty. [Fixes #1088](google-gemini/gemini-cli#1088)
1 parent 5927bf8 commit ad893a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,13 @@ runs:
326326
if jq -e . "${TEMP_STDERR}" >/dev/null 2>&1; then
327327
ERROR_JSON=$(jq -c '.error // empty' "${TEMP_STDERR}")
328328
fi
329-
if ! { jq -e . "${TEMP_STDERR}" >/dev/null 2>&1 && jq -e . "${TEMP_STDOUT}" >/dev/null 2>&1; }; then
329+
if ! jq -e . "${TEMP_STDOUT}" >/dev/null 2>&1; then
330330
echo "::warning::Gemini CLI output was not valid JSON"
331+
# If we failed to parse JSON and the command didn't fail, this is likely a silent failure (e.g. resource limit)
332+
if [[ "${FAILED}" == "false" ]]; then
333+
echo "::error title=Gemini CLI execution failed::Gemini CLI produced invalid or empty JSON output, which usually indicates a silent failure."
334+
FAILED=true
335+
fi
331336
fi
332337
333338

0 commit comments

Comments
 (0)