Fix bash syntax error in sync-pr-to-issue workflow when PR body contains special characters#1560
Draft
Copilot wants to merge 2 commits into
Draft
Fix bash syntax error in sync-pr-to-issue workflow when PR body contains special characters#1560Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…ins special characters Agent-Logs-Url: https://github.com/internetee/auction_center/sessions/8d63168b-7c76-4168-8e25-918a8e84801f Co-authored-by: vohmar <7734747+vohmar@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] Fix GitHub Actions workflow failure in job 70268323374
Fix bash syntax error in sync-pr-to-issue workflow when PR body contains special characters
Apr 7, 2026
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.



Inlining
${{ github.event.pull_request.body }}directly into the bash script causes a syntax error when the PR body contains parentheses, backticks, quotes, or newlines — GitHub Actions renders the expression before bash parses the script.Change
Pass the PR body as an environment variable instead of interpolating it inline:
env: PR_BODY— body is set by the runner before bash executes; special chars are never part of the script sourceprintf '%s'overecho— avoidsechointerpreting escape sequences$GITHUB_OUTPUT— minor correctness fixOriginal prompt
Fix GitHub Actions workflow failure in job 70268323374 (workflow: .github/workflows/sync-pr-to-issue.yml) for PR #1559.
Observed failure (from job logs): bash reports
syntax error near unexpected token '('while running the step that extracts a linked issue number from the PR body.Root cause: the workflow currently inlines
${{ github.event.pull_request.body }}directly into a shell script:When the PR body contains characters like backticks, quotes, parentheses, and/or newlines (as in PR #1559, which includes text about
action_text-trix 2.1.17and abundle-auditvulnerability), the generated bash script becomes syntactically invalid.Task:
.github/workflows/sync-pr-to-issue.ymlto safely extract the first#<number>from the PR body without injecting the raw PR body into the shell script.env: PR_BODY: ${{ github.event.pull_request.body }}and then parse usingprintf '%s' "$PR_BODY".issue_numberto$GITHUB_OUTPUT.Acceptance criteria:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for failing job 70268323374. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The failing job 70268323374 is not failing because of the
bundle-auditvulnerability itself. It’s failing earlier due to a bash syntax error caused by unescaped characters from the PR body being injected into a shell script.What’s happening
In
.github/workflows/sync-pr-to-issue.yml, the first step does:ISSUE=$(echo "${{ github.event.pull_request.body }}" | grep -oE '#[0-9]+' | head -n1 | tr -d '#')Your job log shows the PR body contains text like:
Example from the log includes
Level0InputController)and other punctuation. When GitHub Actions renders${{ github.event.pull_request.body }}into the generated shell script, that content can break the script syntax, producing:So the fix is: don’t inline the PR body into the shell script. Pass it via an environment variable (or use
github-script), and then parse it safely.Fix (recommended): pass PR body via env and parse it
Update the “Extract linked issue number from PR body” step like this:
Key changes:
env: PR_BODY: ...instead of embedding the body directly in the scriptprintf '%s'to avoidechoedge casesThis prevents PR text (including parentheses/backticks/quotes/newlines) from being interpreted by bash.
Alternative fix: extract issue number using
actions/github-scriptIf you prefer avoiding shell parsing entirely:
Either approach will stop the syntax error and allow the rest of the workflow to run normally.
Note on the vulnerability text in the logs
The
action_text-trix 2.1.17/ “update to >= 2.1.18” message appears to just be part of the PR body content that this workflow tried to parse, not the root cause of this job failing. The root cause here is the unsafe interpolation of PR body into bash.User: fix the issue please
Assistant: I’ve queued the workflow fix (safe issue-number extraction by passing the PR body via an environment variable instead of inlining it), and we’re now waiting on your approval in the dialog to apply the change to the repository and push the update.
User: @Copilot Accepted Confirmation: Are you sure?
Assistant: You can fix it by changing the workflow step that extracts the issue number so it doesn’t inline the PR body into the bash script (that’s what’s causing the
syntax error near unexpected token '('when the PR body contains punctuation/newlines).Apply this patch to
.github/workflows/sync-pr-to-issue.yml: