Repository navigation
Description
Summary
gh aw compile (v0.76.x and v0.77.1) hoists GitHub Actions expression tokens (${{ ... }}) from inside # shell comments in a run: block body into the step's env: block. This produces lock files that fail GitHub Actions template loading when the harvested expression evaluates to a non-string (e.g. a wildcard secrets-context reference, which is a sequence).
In v0.71.5 the same source compiled cleanly, so this is a regression in the expression-harvesting pass.
Repro
Source workflow .github/workflows/repro.md:
---
name: Repro
on: workflow_dispatch
permissions:
contents: read
engine: copilot
---
# repro
```yaml
jobs:
show:
runs-on: ubuntu-latest
steps:
- name: Resolve credentials
shell: bash
run: |
set -euo pipefail
# NOTE: the PK is masked because it came from
# a ${{ secrets.* }} reference at compile time.
echo "ok"Compile with gh aw compile (v0.76.1 or v0.77.1). The generated repro.lock.yml step gains a spurious env: entry:
env:
GH_AW_EXPR_36F7BDB0: ${{ secrets.* }}GitHub Actions then rejects the file at load time:
##[error]The template is not valid.
.github/workflows/repro.lock.yml (Line: N, Col: 32): A sequence was not expected
(secrets.* is a wildcard secrets-context filter that evaluates to a sequence, not a string.)
Same regression triggers for any ${{ ... }} token that appears inside a # shell comment in a run: body and resolves to anything that isn't a coercible scalar.
Why it matters in practice
This broke three production workflows in microsoft/apm after a v0.71.5 -> v0.76.1 recompile, because the imported APM credential-prep shared block documented the masking contract in a comment that mentioned the literal ${{ secrets.* }} form. Example failed run: https://github.com/microsoft/apm/actions/runs/26625014231/job/78460262895?pr=1538
Workaround on the user side: rewrite the comment so it does not contain ${{ ... }} syntax. But this is brittle -- legitimate documentation cannot reference Actions expression syntax in any shell comment without risking workflow-load failures.
Expected behaviour
The expression-harvesting pass should not scan inside # shell comments in a run: block body. (Bash treats # as a line comment except inside strings and a few other contexts. A minimal "strip line-comments before scanning" pre-pass would have caught this.)
Alternatively: only harvest expressions that contribute to the actual interpolated script output, not those quoted in comments.
Versions
- gh-aw: regression confirmed in v0.76.1 (latest stable) and v0.77.1 (pre-release). v0.71.5 compiles the same source cleanly.
- Detected via
microsoft/apmPR fix(panels): unbreak panel workflows -- gh-aw v0.76+ harvests expression tokens from bash comments microsoft/apm#1545 (fixes the harvested-comment on the user side).
Related
pull_request_targetwas recently warned about by the compiler -- unrelated to this issue, just calling out the same surface area is being touched.
Activity