-
-
Notifications
You must be signed in to change notification settings - Fork 260
ci(slack): escape mrkdwn + fetch timeout (sync notifier with OGAD) #509
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 |
|---|---|---|
|
|
@@ -35,15 +35,20 @@ const server = process.env.GITHUB_SERVER_URL || 'https://github.com'; | |
| const repo = process.env.GITHUB_REPOSITORY || ''; | ||
| const releaseUrl = process.env.RELEASE_URL || (repo && version ? `${server}/${repo}/releases/tag/v${version}` : ''); | ||
|
|
||
| // Slack mrkdwn reserves & < > — a raw commit subject containing them (release notes are raw | ||
| // commit subjects) would misrender or be read as a <link|mention>. Escape the note body only; | ||
| // NOT the intentional <url|label> link line below. | ||
| const esc = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | ||
|
|
||
| let notes = ''; | ||
| try { notes = readFileSync(notesFile, 'utf8').trim(); } catch { /* notes optional */ } | ||
| // Slack section text caps at 3000 chars; keep well under and never dump a wall. | ||
| if (notes.length > 2600) { notes = `${notes.slice(0, 2600)}\n…`; } | ||
|
|
||
| const tag = label ? ` \`${label}\`` : ''; | ||
| const header = `:package: *${product}* \`${version || 'release'}\`${tag}`; | ||
| const header = `:package: *${esc(product)}* \`${version || 'release'}\`${tag}`; | ||
| const linkLine = releaseUrl ? `<${releaseUrl}|Download / release page>` : ''; | ||
| const body = notes || '_No release notes generated for this build._'; | ||
| const body = notes ? esc(notes) : '_No release notes generated for this build._'; | ||
|
Comment on lines
+41
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Escape breaks length cap In notify-slack-release.mjs, release notes are truncated to 2600 characters before being escaped, but esc() can expand the text (e.g., '&' → '&') and push the final mrkdwn section over the 3000-character Slack limit. This can cause Slack to reject the block/payload and drop the release announcement despite the pre-escape truncation. Agent Prompt
|
||
|
|
||
| const blocks = [ | ||
| { type: 'section', text: { type: 'mrkdwn', text: header } }, | ||
|
Comment on lines
+38
to
54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Slack notifier missing regression test The PR changes Slack message escaping and adds fetch timeouts, which alters release-notification behavior but does not include an automated regression test to pin the new behavior. This risks silent regressions in the release workflow and violates the requirement to add/update tests for behavior changes. Agent Prompt
|
||
|
|
@@ -59,6 +64,7 @@ try { | |
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json; charset=utf-8' }, | ||
| body: JSON.stringify({ text: fallbackText, blocks, unfurl_links: false }), | ||
| signal: AbortSignal.timeout(10000), | ||
| }); | ||
| const t = await res.text().catch(() => ''); | ||
| if (!res.ok) { warn(`webhook not ok: HTTP ${res.status} ${t}`); process.exit(0); } | ||
|
|
@@ -68,6 +74,7 @@ try { | |
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json; charset=utf-8', Authorization: `Bearer ${token}` }, | ||
| body: JSON.stringify({ channel, text: fallbackText, blocks, unfurl_links: false }), | ||
| signal: AbortSignal.timeout(10000), | ||
| }); | ||
| const j = await res.json().catch(() => ({})); | ||
| if (!res.ok || !j.ok) { warn(`chat.postMessage not ok: HTTP ${res.status} ${j.error || ''}`); process.exit(0); } | ||
|
|
||
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.
3. Escape comment mismatch
🐞 Bug⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools