Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/notifications/channels/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function convertSlackToDiscord(slackPayload) {
if (block.type === 'section' && block.text) {
descriptionLines.push(block.text.text);
}
if (block.type === 'fields' && block.fields) {
// Fields ride on a section block; 'fields' is tolerated for older payloads.
if ((block.type === 'section' || block.type === 'fields') && block.fields) {
for (const f of block.fields) {
Comment on lines +24 to 26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Legacy fields branch untested 📜 Skill insight ▣ Testability

A new backward-compatibility branch was added so Slack block parsing accepts both section blocks
with fields and legacy block.type === 'fields', but the existing notification channel tests only
exercise the section path. This leaves the legacy conversion path unverified and risks regressions
for persisted/in-flight payloads shipping unnoticed.
Agent Prompt
## Issue description
Converters now accept both `section` blocks with `fields` and legacy `block.type === 'fields'`, but current tests only exercise the new `section` shape via `formatSlackStageMessage`, leaving the backward-compatibility branch untested.

## Issue Context
This PR explicitly aims to tolerate older persisted/in-flight Slack payloads; without a dedicated test that includes a legacy `{ type: 'fields', fields: [...] }` block, that compatibility guarantee can regress silently. Add a test that feeds a legacy Slack payload using `type: 'fields'` into each converter (e.g., `slackPayloadToText`, `convertSlackToDiscord`, `convertSlackToTeams`) and asserts the expected extracted fields / outputs.

## Fix Focus Areas
- tests/notifications-channels.test.js[19-42]
- src/notifications/channels/discord.js[20-33]
- src/notifications/channels/teams.js[17-40]
- src/notifications/channels/text.js[21-34]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

const raw = f.text || '';
const parts = raw.split('\n');
Expand Down
3 changes: 2 additions & 1 deletion src/notifications/channels/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export function convertSlackToTeams(slackPayload) {
facts: []
});
}
if (block.type === 'fields' && block.fields) {
// Fields ride on a section block; 'fields' is tolerated for older payloads.
if ((block.type === 'section' || block.type === 'fields') && block.fields) {
const currentSection = sections[sections.length - 1] || { facts: [] };
if (!sections.includes(currentSection)) {
sections.push(currentSection);
Expand Down
3 changes: 2 additions & 1 deletion src/notifications/channels/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export function slackPayloadToText(slackPayload) {
if (block.type === 'section' && block.text?.text) {
lines.push(stripMrkdwn(block.text.text));
}
if (block.type === 'fields' && Array.isArray(block.fields)) {
// Fields ride on a section block; 'fields' is tolerated for older payloads.
if ((block.type === 'section' || block.type === 'fields') && Array.isArray(block.fields)) {
for (const field of block.fields) {
const parts = String(field.text ?? '').split('\n');
const name = stripMrkdwn(parts[0]);
Expand Down
6 changes: 4 additions & 2 deletions src/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export function formatSlackStageMessage(runId, stageId, status, details = {}) {
},
},
{
type: 'fields',
// Block Kit has no 'fields' block type — fields live on a section block.
type: 'section',
fields,
},
];
Expand Down Expand Up @@ -146,7 +147,8 @@ export function formatSlackTaskReportMessage(runId, taskId, trace) {
},
},
{
type: 'fields',
// Block Kit has no 'fields' block type — fields live on a section block.
type: 'section',
fields: [
{ type: 'mrkdwn', text: `*Run ID:*\n${runId}` },
{ type: 'mrkdwn', text: `*Task:*\n${taskId}` },
Expand Down
Loading