From b1a7c23fcf47f306f053bead39737389acd70bcf Mon Sep 17 00:00:00 2001 From: "augmentcode[bot]" <185243770+augmentcode[bot]@users.noreply.github.com> Date: Tue, 25 Aug 2026 06:43:10 +0000 Subject: [PATCH] Fix backfillReportingChannel to actually resolve channel by name resolveSlackChannelId previously just echoed back whatever configuredChannelId was passed in, so the script could never populate Event.slackReportingChannelId for events that didn't already have one, and the --channel flag was silently ignored. - resolveSlackChannelId now looks up the channel by name via findSlackChannelByName when no configured ID is present, and returns its id. - backfillReportingChannel.ts passes channelName through, and passes null instead of the existing value when --force is set so lookups can overwrite a stale configured ID. --- scripts/backfillReportingChannel.ts | 8 ++++++-- src/slack/findSlackChannelByName.ts | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/backfillReportingChannel.ts b/scripts/backfillReportingChannel.ts index 97011e4..693ef7e 100644 --- a/scripts/backfillReportingChannel.ts +++ b/scripts/backfillReportingChannel.ts @@ -55,11 +55,15 @@ async function main() { try { const slack = getSlackClientForEvent(event); - const channelId = await resolveSlackChannelId(slack, event.slackReportingChannelId); + const channelId = await resolveSlackChannelId( + slack, + force ? null : event.slackReportingChannelId, + channelName, + ); if (!channelId) { skippedNotFound += 1; - console.log(`- ${event.id}: no configured reporting channel ID, skipping`); + console.log(`- ${event.id}: could not find #${channelName} in this workspace, skipping`); continue; } diff --git a/src/slack/findSlackChannelByName.ts b/src/slack/findSlackChannelByName.ts index 305ab54..2b108b5 100644 --- a/src/slack/findSlackChannelByName.ts +++ b/src/slack/findSlackChannelByName.ts @@ -27,9 +27,17 @@ export async function findSlackChannelByName( )); } +/** + * Returns the channel ID to use for reporting: the already-configured ID if + * one is set, otherwise looks up `channelName` in the workspace by name. + */ export async function resolveSlackChannelId( - _slack: Pick, + slack: Pick, configuredChannelId: string | null, + channelName: string, ): Promise { - return configuredChannelId; + if (configuredChannelId) return configuredChannelId; + + const channel = await findSlackChannelByName(slack, channelName); + return channel?.id ?? null; } \ No newline at end of file