fix(ci): pass commits JSON via env block to avoid bash quoting break
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 23s
Harness Replays / detect-changes (pull_request) Successful in 17s
CI / Detect changes (pull_request) Successful in 1m2s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m8s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 1m7s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 15s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 21s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 1m5s
sop-tier-check / tier-check (pull_request) Successful in 18s
Harness Replays / Harness Replays (pull_request) Successful in 9s
CI / Platform (Go) (pull_request) Successful in 9s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 7s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m4s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 12s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 14s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 2m31s
CI / Python Lint & Test (pull_request) Successful in 7m39s
CI / Canvas (Next.js) (pull_request) Failing after 8m0s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 7m52s

The detect-changes step's push path used `echo '${{ toJSON(github.event.commits) }}'`
which broke on every main push because every main commit is a Gitea merge commit
whose message contains single quotes (e.g. "Merge pull request 'fix: ...' from branch
into main"). The embedded `'` ended the single-quoted bash string mid-JSON, and a
subsequent `(` (e.g. in "#523)") was parsed as a subshell → "syntax error near
unexpected token `('". This caused detect-changes to exit 2 → main-red.

Fix: pass the JSON via an `env:` block (env values bypass shell quoting entirely)
and pipe it to the script using `printf '%s' "$COMMITS_JSON"`.

Closes #526.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · core-devops 2026-05-11 17:38:16 +00:00
parent b6a5825105
commit c36bbce76f

View File

@ -74,6 +74,16 @@ jobs:
# GitHub event variables, so no local history is needed.
fetch-depth: 1
- id: decide
env:
# Pass via env block — env values bypass shell quoting so single
# quotes in merge-commit messages (e.g. "Merge pull request 'fix: ...'
# from branch into main") cannot break the bash parser. The prior
# `echo '${{ toJSON(...) }}'` form broke on every main-push because
# every main commit is a merge commit with single quotes in the
# message body — the embedded `'` ended the single-quoted shell string
# mid-JSON, and a subsequent `(` (e.g. in `(#523)`) was parsed as a
# subshell, causing "syntax error near unexpected token `('".
COMMITS_JSON: ${{ toJSON(github.event.commits) }}
run: |
set -euo pipefail
@ -98,7 +108,7 @@ jobs:
# Gitea Compare API rejects SHA-to-branch comparisons (BaseNotExist),
# so we use the commits array instead. This array contains all commits
# in the push, each with their added/removed/modified file lists.
echo '${{ toJSON(github.event.commits) }}' \
printf '%s' "$COMMITS_JSON" \
| bash .gitea/scripts/push-commits-diff-files.py \
> .push-diff-files.txt 2>/dev/null || true
DIFF_FILES=$(cat .push-diff-files.txt 2>/dev/null || true)