Skip to content

Commit e4659a4

Browse files
committed
fix(webhooks): keep calling reactions.get after a missing-scope report
Skipping the call for the cooldown window left a reinstalled Slack bot with empty reaction text for up to an hour. Keep the once-per-window log but always make the call. Block listing also uses the lightweight custom-block rows, since block summaries never read custom block inputs.
1 parent d08916b commit e4659a4

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎apps/sim/lib/catalog/application/list-blocks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const listCatalogBlocks = defineAuthorizedWorkspaceUseCase({
7979
authorizationOptions: { delegation: catalogDelegationPolicy },
8080
execute: async ({ principal, input, context }): Promise<ListCatalogBlocksResult> => {
8181
const search = normalizeCatalogSearch(input.search)
82-
const gate = await resolveCatalogGate(principal, context, { customBlockInputs: true })
82+
const gate = await resolveCatalogGate(principal, context)
8383

8484
const summaries = await withCatalogBlockScope(gate, async () => [
8585
...getAllBlocks()

‎apps/sim/lib/webhooks/providers/slack.ts‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,12 @@ async function downloadSlackFiles(
409409
}
410410

411411
/**
412-
* Webhooks whose bot reported `missing_scope` on `reactions.get`. A bot without
412+
* Webhooks whose bot already reported `missing_scope` on `reactions.get`. A bot without
413413
* `reactions:read` fails every reaction event identically until it is reinstalled, so the
414-
* call is skipped (and the configuration problem logged once) for the rest of the window.
414+
* configuration problem is logged once per webhook per window rather than per event. The call
415+
* itself still runs, so a reinstalled bot gets message text back immediately.
415416
*/
416-
const reactionsScopeMissing = new LRUCache<string, true>({
417+
const reactionsMissingScopeLogged = new LRUCache<string, true>({
417418
max: 10_000,
418419
ttl: 60 * 60 * 1000,
419420
})
@@ -424,7 +425,6 @@ async function fetchSlackMessageText(
424425
botToken: string,
425426
webhookId: string
426427
): Promise<string> {
427-
if (reactionsScopeMissing.has(webhookId)) return ''
428428
try {
429429
const params = new URLSearchParams({ channel, timestamp: messageTs })
430430
const response = await fetch(`https://slack.com/api/reactions.get?${params}`, {
@@ -439,11 +439,13 @@ async function fetchSlackMessageText(
439439
}
440440
if (!data.ok) {
441441
if (data.error === 'missing_scope') {
442-
reactionsScopeMissing.set(webhookId, true)
443-
logger.info('Slack bot lacks a scope for reactions.get — reaction message text omitted', {
444-
webhookId,
445-
needed: data.needed,
446-
})
442+
if (!reactionsMissingScopeLogged.has(webhookId)) {
443+
reactionsMissingScopeLogged.set(webhookId, true)
444+
logger.info('Slack bot lacks a scope for reactions.get — reaction message text omitted', {
445+
webhookId,
446+
needed: data.needed,
447+
})
448+
}
447449
return ''
448450
}
449451
logger.warn('Slack reactions.get failed — message text unavailable', {

0 commit comments

Comments
 (0)