Skip to content

Fix shell quoting in coverage-comment workflow#845

Merged
mjp41 merged 1 commit intomicrosoft:mainfrom
mjp41:coverage-fix
May 7, 2026
Merged

Fix shell quoting in coverage-comment workflow#845
mjp41 merged 1 commit intomicrosoft:mainfrom
mjp41:coverage-fix

Conversation

@mjp41
Copy link
Copy Markdown
Member

@mjp41 mjp41 commented May 7, 2026

The "Resolve PR number" step embedded the event JSON via <<<'${{ toJson(github.event) }}'. Actions performs the ${{...}} interpolation before bash parses the script, so the single-quoted heredoc string contained the entire raw event payload inline. As soon as the payload contained a single quote — e.g. an apostrophe in a commit message, branch name, or any string field — bash's '...' quoting closed early and the rest of the step's body became malformed, producing the GitHub-Actions error:

syntax error near unexpected token else

(reported against the assembled temp script's line number, not the workflow file's). The first PR opened after the coverage workflow landed happened to have such a quote.

Pass the JSON via an environment variable instead. The shell sees only "$EVENT_JSON", which is safe regardless of what characters the payload contains. Add a comment recording the failure mode so no future maintainer reintroduces the inline-interpolation pattern.

The "Resolve PR number" step embedded the event JSON via
`<<<'${{ toJson(github.event) }}'`. Actions performs the `${{...}}`
interpolation *before* bash parses the script, so the single-quoted
heredoc string contained the entire raw event payload inline. As
soon as the payload contained a single quote — e.g. an apostrophe
in a commit message, branch name, or any string field — bash's
'...' quoting closed early and the rest of the step's body became
malformed, producing the GitHub-Actions error:

  syntax error near unexpected token `else`

(reported against the assembled temp script's line number, not the
workflow file's). The first PR opened after the coverage workflow
landed happened to have such a quote.

Pass the JSON via an environment variable instead. The shell sees
only `"$EVENT_JSON"`, which is safe regardless of what characters
the payload contains. Add a comment recording the failure mode so
no future maintainer reintroduces the inline-interpolation pattern.
@mjp41 mjp41 merged commit 34c9d32 into microsoft:main May 7, 2026
197 checks passed
@mjp41 mjp41 deleted the coverage-fix branch May 7, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant