-
Notifications
You must be signed in to change notification settings - Fork 5
fix(gha): convert markdown to Slack markdown to urls are properly unf… #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ on: | |||||
| workflow_call: | ||||||
| inputs: | ||||||
| commit_message: | ||||||
| description: 'Commit message to check for skip markers' | ||||||
| description: "Commit message to check for skip markers" | ||||||
| required: false | ||||||
| type: string | ||||||
| secrets: | ||||||
|
|
@@ -66,11 +66,11 @@ jobs: | |||||
| - name: Validate installation | ||||||
| shell: bash | ||||||
| run: | | ||||||
| OUTPUT=$(uv run --all-extras --no-dev aignostics --help) | ||||||
| if [[ "$OUTPUT" != *"built with love in Berlin"* ]]; then | ||||||
| echo "Output does not contain 'built with love in Berlin'" | ||||||
| exit 1 | ||||||
| fi | ||||||
| OUTPUT=$(uv run --all-extras --no-dev aignostics --help) | ||||||
| if [[ "$OUTPUT" != *"built with love in Berlin"* ]]; then | ||||||
| echo "Output does not contain 'built with love in Berlin'" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| - name: Install upx for native Windows version | ||||||
| if: ${{ matrix.runner == 'windows-latest' || matrix.runner == 'windows-11-arm' }} | ||||||
|
|
@@ -219,7 +219,7 @@ jobs: | |||||
| rm -rf ./test-results/coverage_html | ||||||
| gh release create ${{ github.ref_name }} ./dist/* ./dist_native_zipped/* ./audit-results/* \ | ||||||
| --notes-file ${{ steps.git-cliff.outputs.changelog }} | ||||||
|
|
||||||
| - name: Inform Sentry about release | ||||||
| uses: getsentry/action-release@dab6548b3c03c4717878099e43782cf5be654289 # v3.5.0 | ||||||
| env: | ||||||
|
|
@@ -230,6 +230,19 @@ jobs: | |||||
| environment: production | ||||||
| release: ${{ github.ref_name }} | ||||||
|
|
||||||
| - name: Convert release notes from Markdown to Slack mrkdwn | ||||||
| id: slack-notes | ||||||
| shell: bash | ||||||
| run: | | ||||||
| # Convert Markdown links [text](url) to Slack mrkdwn <url|text> | ||||||
| # Convert bold **text** to *text* | ||||||
| SLACK_RELEASE_NOTES=$(echo '${{ toJSON(steps.git-cliff.outputs.content) }}' | \ | ||||||
| sed -E 's/\[([^]]+)\]\(([^)]+)\)/<\2|\1>/g' | \ | ||||||
| sed -E 's/\*\*([^*]+)\*\*/*\1*/g') | ||||||
| echo "content<<SLACKEOF" >> "$GITHUB_OUTPUT" | ||||||
| echo "$SLACK_RELEASE_NOTES" >> "$GITHUB_OUTPUT" | ||||||
| echo "SLACKEOF" >> "$GITHUB_OUTPUT" | ||||||
|
|
||||||
| - name: Release Announcement | ||||||
| uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 | ||||||
| with: | ||||||
|
|
@@ -238,7 +251,7 @@ jobs: | |||||
| payload: | | ||||||
| "repository": "${{ github.repository }}", | ||||||
| "version": "${{ steps.git-cliff.outputs.version }}", | ||||||
| "release_notes": ${{ toJSON(steps.git-cliff.outputs.content) }}, | ||||||
| "release_notes": ${{ steps.slack-notes.outputs.content }}, | ||||||
|
||||||
| "release_notes": ${{ steps.slack-notes.outputs.content }}, | |
| "release_notes": ${{ toJSON(steps.slack-notes.outputs.content) }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The release_notes value is not wrapped with toJSON(), which will create an invalid payload for the Slack action if the notes contain special characters or newlines.
Severity: MEDIUM
Suggested Fix
To ensure the payload is always valid JSON, wrap the output variable in a toJSON() call. The line should be changed to: "release_notes": ${{ toJSON(steps.slack-notes.outputs.content) }},.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: .github/workflows/_package-publish.yml#L254
Potential issue: In the `_package-publish.yml` workflow, the `release_notes` field is
populated with raw, potentially multiline content that may contain special characters.
This content is not properly escaped using `toJSON()` before being inserted into the
payload for the `slackapi/slack-github-action`. When the action attempts to parse this
payload, the unescaped value will break the JSON/YAML structure. This will cause the
'Release Announcement' step to fail, preventing release notifications from being sent to
the designated Slack channel.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversion uses
toJSON(steps.git-cliff.outputs.content)and then echoes it as a literal string, which produces a JSON-escaped value (surrounding quotes and escaped\n). That meanssedwill run against the escaped representation and the Slack output is likely to contain quotes/backslashes instead of proper newlines/markdown. Consider passing the raw content into the step (e.g., via an env var) or explicitly decoding the JSON string before running thesedtransforms.