Description
When using " on a Pull Request title the JSON payload is broken.
What type of issue is this? (place an x in one of the [ ])
Requirements (place an x in each of the [ ])
Bug Report
When placing a " on the Pull Request title, for example Add new field "image", the JSON payload gets broken.
Reproducible in:
package version: action version v1.23.0
node version:
OS version(s):
Steps to reproduce:
- Add
" to Pull Request title
- Execute GH Action and expect to fail
Expected result:
Be able to place " on Pull Request title without breaking JSON payload.
Actual result:
JSON payload is broken.
Console error:
Run slackapi/slack-github-action@v1.23.0
Error: Error: Need to provide valid JSON payload
passed in payload was invalid JSON
Attachments:
Our current use of this GitHub Action from we get this issue.
name: Notifying slack
on:
pull_request:
types: [ labeled ]
jobs:
notify-slack:
runs-on: small
if: ${{ github.event.label.name == 'slack-notification'}}
steps:
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"repository": "${{ github.repository }}",
"pull_request_username": "${{ github.event.pull_request.user.login }}",
"pull_request_title": "${{ github.event.pull_request.title }}",
"pull_request_url": "${{ github.event.pull_request.html_url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
A possible fix for this could be having something like this following workflow but inside the GitHub Action.
name: Notifying slack
on:
pull_request:
types: [ labeled ]
jobs:
variables:
outputs:
pr_title: ${{ steps.var.outputs.pr_title}}
runs-on: small
steps:
- name: Setting global variables
uses: actions/github-script@v6
id: var
with:
script: |
core.setOutput('pr_title', '${{ github.event.pull_request.title }}'.replaceAll(/[/"]/g, '\''));
notify-slack:
needs: [variables]
runs-on: small
if: ${{ github.event.label.name == 'slack-notification'}}
steps:
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"repository": "${{ github.repository }}",
"pull_request_username": "${{ github.event.pull_request.user.login }}",
"pull_request_title": "${{ needs.variables.outputs.pr_title }}",
"pull_request_url": "${{ github.event.pull_request.html_url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
Description
When using
"on a Pull Request title the JSON payload is broken.What type of issue is this? (place an
xin one of the[ ])Requirements (place an
xin each of the[ ])Bug Report
When placing a
"on the Pull Request title, for exampleAdd new field "image", the JSON payload gets broken.Reproducible in:
package version: action version v1.23.0
node version:
OS version(s):
Steps to reproduce:
"to Pull Request titleExpected result:
Be able to place
"on Pull Request title without breaking JSON payload.Actual result:
JSON payload is broken.
Console error:
Attachments:
Our current use of this GitHub Action from we get this issue.
A possible fix for this could be having something like this following workflow but inside the GitHub Action.