Skip to content

Commit 92eadcf

Browse files
ci: send the Slack payload as JSON with a literal-newline message
slack-github-action v4 ships js-yaml v5, which enforces stricter multiline indentation. MESSAGE was a double-quoted YAML scalar, so its \n\n became real newlines that were interpolated into the YAML payload at column 0 and broke the document: Invalid input! Failed to parse contents of the provided payload SyntaxError: Expected property name or '}' in JSON at position 1 Single-quote MESSAGE so \n stays a two-character escape, and send the payload as JSON, where an interpolated message cannot break the structure and \n is exactly the newline Slack mrkdwn renders. Verified end to end on a throwaway branch: the notify job was forced to run under dryRun and delivered to Slack with errors: true, so a rejected delivery would have failed the step.
1 parent 87bc8a8 commit 92eadcf

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/weekly-release.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,25 @@ jobs:
9999
- name: "Send Message"
100100
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
101101
env:
102-
MESSAGE: "_*Weekly RIE release failed*_ :turtle-headache::broken_heart:\n\nNo new pre-release was published, so CVE remediation is stalled until this is fixed. Investigate the failed workflow run <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here> :mag_right:"
102+
# Single-quoted so \n stays a two-character escape. In a double-quoted YAML scalar it
103+
# becomes a real newline, which lands unindented inside the payload below and breaks
104+
# parsing under the stricter js-yaml v5 rules that slack-github-action v4 ships.
105+
MESSAGE: '_*Weekly RIE release failed*_ :turtle-headache::broken_heart:\n\nNo new pre-release was published, so CVE remediation is stalled until this is fixed. Investigate the failed workflow run <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here> :mag_right:'
103106
with:
104107
webhook: ${{ secrets.COSY_WEBHOOK_URL }}
105108
webhook-type: incoming-webhook
106109
# Default is false, which swallows Slack-side delivery errors and reports the step as
107110
# green. For the alert that tells us releases are broken, a silent failure is the one
108111
# outcome we cannot afford.
109112
errors: true
113+
# JSON rather than YAML: an interpolated message cannot break the document structure,
114+
# and \n inside a JSON string is exactly the newline Slack mrkdwn wants.
110115
payload: |
111-
blocks:
112-
- type: "section"
113-
text:
114-
type: "mrkdwn"
115-
text: "${{ env.MESSAGE }}"
116+
{
117+
"blocks": [
118+
{
119+
"type": "section",
120+
"text": { "type": "mrkdwn", "text": "${{ env.MESSAGE }}" }
121+
}
122+
]
123+
}

0 commit comments

Comments
 (0)