Cannot use ${{ toJson(github) }} when a ' appears in the commit message.
See original GitHub issueDescribe the bug When trying to use ${{ toJson(github) }} when there is a ’ in the commit message, you get an error. The error looks like, unexpected EOF while looking for matching `"’
To Reproduce Steps to reproduce the behavior:
- Have a workflow bash script that tries to run ${{ toJson(github) }} that runs on a PR
- Leave a commit message including a ’ character
- Trigger the workflow by opening a PR
- You should see the toJson step fail with the error message above.
Expected behavior Expected to see the full pretty printed github context
Runner Version and Platform
Current runner version: ‘2.287.1’
OS of the machine running the runner? OSX/Windows/Linux/… Ubuntu 20.04.3 LTS
What’s not working?
toJson expression
Job Log Output
unexpected EOF while looking for matching `"’
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
GitHub Action Get Commit Message
Or it is possible to get the commit messages with the git log command if you use bash: git log -1 --pretty=format:"%s".
Read more >Source Control with Git in Visual Studio Code
You can find the details in Git commit information. Stage all changes button. You can type a commit message above the changes and...
Read more >Returning Git Commit Information as JSON
No one cannot remember who updated the server X or when it was updated. ... Let's find out how we can configure the...
Read more >Push rules | GitLab
This push rule requires a Signed-off-by: trailer in every commit message, ... Do not allow users to remove Git tags with git push...
Read more >Comments on individual commits made outside a pull ...
A commit comment cannot be added from the pull request page and cannot be replied to or resolved like a pull request review...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @petersutter5,
I reproduced the issue. toJSON will create a JSON object, and since ’ is a valid thing to be inside the name (strings are enclosed using "), it will not be escaped. Now, if you are using an expression like
echo '${{ toJSON(github) }}'
, it will trigger a parsing error when it gets to the ’ inside the"title"
.One suggestion can be to pass in the context as env variable, and then printing or using it would not cause an issue:
This is a bash error, and you can take advantage of bash’s built-in escaping of env variables to solve the problem like in the workflow above.
@nikola-jokic , thanks for the workaround, but note that official documentation also contains example that triggers this issue, without warning about escaping issues It would be nice to add second warning there about this issue and potential workaround