-
Notifications
You must be signed in to change notification settings - Fork 244
bug: EOF heredoc delimiter collision in GITHUB_OUTPUT causes step failure #490
Description
TL;DR
The action uses EOF as the heredoc delimiter when writing gemini_response and gemini_errors to $GITHUB_OUTPUT. When Gemini CLI's stderr contains the substring EOF (e.g. from internal bash parser diagnostics like SCRIPT_EOF), it prematurely terminates the heredoc block. The remaining stderr content is then parsed as raw $GITHUB_OUTPUT format, which GitHub Actions rejects with:
##[error]Unable to process file command 'output' successfully.
##[error]Invalid format 'SCRIPT_EOF Syntax Errors: [ 'Error node: "<" at 0:0' ]'
This is related to #381, which reports the same underlying issue from a different angle (JSON output containing EOF leaking into the next output block).
Root Cause
In action.yml, the output blocks use EOF as the delimiter:
echo "gemini_errors<<EOF" >> "${GITHUB_OUTPUT}"
if [[ -n "${ERROR_JSON}" ]]; then
echo "${ERROR_JSON}" >> "${GITHUB_OUTPUT}"
else
cat "${TEMP_STDERR}" >> "${GITHUB_OUTPUT}"
fi
echo "EOF" >> "${GITHUB_OUTPUT}"When TEMP_STDERR contains Gemini CLI's internal bash parser warnings (which include the string SCRIPT_EOF), the EOF at position 7 of SCRIPT_EOF matches the heredoc terminator on a line by itself, breaking the block.
The same issue applies to gemini_response<<EOF when stdout JSON happens to contain EOF on its own line.
Reproduction
This is intermittent — it depends on whether Gemini CLI's bash command parser emits syntax warnings containing EOF during a given run. More likely when the agent writes heredoc scripts (e.g. cat << 'SCRIPT_EOF' > file.py).
Observed on: run-gemini-cli@v0.1.21, still present on latest main (642deeb7).
Suggested Fix
Use a more unique delimiter that won't appear in Gemini CLI output:
echo "gemini_errors<<GEMINI_CLI_OUTPUT_DELIMITER" >> "${GITHUB_OUTPUT}"
...
echo "GEMINI_CLI_OUTPUT_DELIMITER" >> "${GITHUB_OUTPUT}"Or use a random delimiter per run:
DELIMITER="GEMINI_EOF_$(openssl rand -hex 8)"
echo "gemini_errors<<${DELIMITER}" >> "${GITHUB_OUTPUT}"
...
echo "${DELIMITER}" >> "${GITHUB_OUTPUT}"Environment
- Action version: v0.1.21
- Runner: ubuntu-latest
- Gemini model: gemini-3.1-pro-preview