Fix shell quoting in coverage-comment workflow#845
Merged
mjp41 merged 1 commit intomicrosoft:mainfrom May 7, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.