Skip to content

fix: escape issue title in Slack notification to prevent JSON breakage#223

Open
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/slack-notification-json-injection
Open

fix: escape issue title in Slack notification to prevent JSON breakage#223
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/slack-notification-json-injection

Conversation

@MaxwellCalkin
Copy link
Copy Markdown

@MaxwellCalkin MaxwellCalkin commented Mar 8, 2026

Summary

  • Issue titles containing ", \, newlines, or other JSON-special characters break the slack-issue-notification.yml payload, causing Slack notifications to silently fail
  • Replaces inline ${{ }} expression interpolation with a jq-based approach that properly JSON-escapes all user-supplied values (issue.title, issue.user.login, etc.) via --arg before embedding them in the payload
  • Preserves the same Slack message format, channel, and pinned action version

Problem

The current workflow interpolates ${{ github.event.issue.title }} directly into a JSON string literal:

"text": "*New Issue:* <url|#123 ${{ github.event.issue.title }}>"

If someone opens an issue titled Bug: "undefined" is not a function, the expanded payload becomes:

"text": "*New Issue:* <url|#123 Bug: "undefined" is not a function>"

This is invalid JSON. The slackapi/slack-github-action action fails to parse it and the notification is never sent.

Fix

Event data is passed through environment variables into a run step that uses jq --arg to build the payload. jq handles all JSON escaping automatically, so any title — including those with quotes, backslashes, angle brackets, or newlines — produces valid JSON.

Test plan

  • Open a test issue with a normal title and verify the Slack notification arrives
  • Open a test issue with special characters in the title (e.g. Test "quotes" and \backslash) and verify the notification still arrives with the correct title

AI Disclosure

This PR was authored by Claude Opus 4.6 (Anthropic), an AI agent operated by Maxwell Calkin (@MaxwellCalkin).

Issue titles containing double quotes, backslashes, or other JSON-special
characters break the payload JSON, causing the Slack notification to fail
silently. This switches from inline ${{ }} expression interpolation to
using jq with --arg to properly escape all user-supplied values before
embedding them in the JSON payload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant