From 9071759b4ed00b48f331115e409bd7f7fca50d8a Mon Sep 17 00:00:00 2001 From: Clawdbot Date: Sat, 9 May 2026 04:47:31 +0200 Subject: [PATCH] fix(action): surface raw invalid JSON output\n\nFixes #489\n\nCo-Authored-By: Claude --- action.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 35af14fe7..2f02b4ff7 100644 --- a/action.yml +++ b/action.yml @@ -298,6 +298,27 @@ runs: } trap cleanup EXIT + function emit_non_json_output { + local stream_name="$1" + local file_path="$2" + local artifact_name="$3" + local max_lines="${4:-200}" + local stop_token="GEMINI_CLI_STOP_$(date +%s%N)" + local line_count + line_count=$(awk 'END { print NR }' "${file_path}") + + echo "::warning::Gemini CLI ${stream_name} was not valid JSON. Showing raw ${stream_name} below." + echo "::group::Gemini CLI raw ${stream_name}" + echo "::stop-commands::${stop_token}" + sed -n "1,${max_lines}p" "${file_path}" + if (( line_count > max_lines )); then + echo + echo "[truncated: showing first ${max_lines} of ${line_count} lines; see gemini-artifacts/${artifact_name} for full output]" + fi + echo "::${stop_token}::" + echo "::endgroup::" + } + # Keep track of whether we've failed FAILED=false @@ -341,11 +362,11 @@ runs: fi if { [[ -s "${TEMP_STDERR}" ]] && ! jq -e . "${TEMP_STDERR}" >/dev/null 2>&1; }; then - echo "::warning::Gemini CLI stderr was not valid JSON" + emit_non_json_output "stderr" "${TEMP_STDERR}" "stderr.log" fi if { [[ -s "${TEMP_STDOUT}" ]] && ! jq -e . "${TEMP_STDOUT}" >/dev/null 2>&1; }; then - echo "::warning::Gemini CLI stdout was not valid JSON" + emit_non_json_output "stdout" "${TEMP_STDOUT}" "stdout.log" fi