google-github-actions / google-github-actions/run-gemini-cli
bug: EOF heredoc delimiter collision in GITHUB_OUTPUT causes step failure
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 285
- Avg merge
- 8h 8m
- Merged PRs (30d)
- 1
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the output-writing blocks in action.yml, focusing on the gemini_response and gemini_errors heredoc delimiters used with GITHUB_OUTPUT. Reproduce with stderr or stdout containing EOF, then verify that the action accepts the outputs without treating embedded Gemini CLI text as raw output format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, shell
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100