Skip to content

Commit be61b2d

Browse files
committed
improvement(slack): warn on usr_ marker parse miss, drop dead bot prefix
1 parent 7820925 commit be61b2d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • apps/sim/app/api/tools/slack/channels

apps/sim/app/api/tools/slack/channels/route.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,20 @@ interface SlackChannel {
3131
* `is_member` filter — no regression.
3232
*/
3333
const SCOPED_USER_ID_PATTERN =
34-
/-usr_([UWB][A-Z0-9]+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
34+
/-usr_([UW][A-Z0-9]+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
3535

3636
function parseScopedSlackUserId(accountId: string): string | null {
3737
const match = SCOPED_USER_ID_PATTERN.exec(accountId)
38-
return match ? match[1] : null
38+
if (match) return match[1]
39+
// A marker is present but the id didn't parse — surface it instead of
40+
// silently dropping to the bot `is_member` filter, which would bypass the
41+
// installer-scoped privacy check without any signal.
42+
if (accountId.includes('-usr_')) {
43+
logger.warn('Slack accountId carries usr_ marker but did not parse; using is_member fallback', {
44+
accountId,
45+
})
46+
}
47+
return null
3948
}
4049

4150
export const POST = withRouteHandler(async (request: NextRequest) => {

0 commit comments

Comments
 (0)