Skip to content

fix(slack): warn (not error) on routine Slack API conditions#3664

Merged
bokelley merged 1 commit into
mainfrom
bokelley/quiet-slack-expected-errors
Apr 30, 2026
Merged

fix(slack): warn (not error) on routine Slack API conditions#3664
bokelley merged 1 commit into
mainfrom
bokelley/quiet-slack-expected-errors

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Stop paging on routine Slack API conditions — three alerts today (3:59, 6:55, 6:57 AM UTC) were :rotating_light: *System error: slack-client* for what are normal third-party states.

What was paging

Time Where Slack error Why it's not a system failure
03:59 inviteToChannel (slack/client.ts:1122) not_in_channel Bot isn't in the channel yet — the caller's job to handle
06:55 getSlackUser (slack/client.ts:243) user_not_found Deactivated/deleted user, or stale reference from an old message
06:57 getSlackUser user_not_found Same

Both functions already do the right thing (return null / { ok: false, error }); only the log level was wrong.

Fix

  • getSlackUser: log user_not_found at warn, everything else still error.
  • inviteToChannel: log not_in_channel, channel_not_found, is_archived, user_is_restricted, user_is_ultra_restricted, user_disabled at warn. Unknown failures still error.

Follows the logger.error vs logger.warn convention added in #3650's JSDoc — error level triggers Slack #aao-errors and PostHog $exception, so it should be reserved for unexpected, page-worthy failures.

Out of scope

There are 11 other logger.error sites in slack/client.ts (and many more across addie/mcp/*). Triaging the lot would be a much bigger PR with a lot of judgment calls about which Slack codes are "routine" per call site. This PR fixes only the three that fired today; the rest will follow as alerts surface, which is the lower-risk way to grade them.

Test plan

  • tsc --noEmit — clean
  • Pre-commit (test:unit + test-dynamic-imports + typecheck) — passed
  • Watch #aao-errors for absence of system-error alerts on not_in_channel / user_not_found

🤖 Generated with Claude Code

Two call sites in slack/client.ts fired ":rotating_light: System error:
slack-client" alerts today for what are routine third-party states, not
server failures:

- getSlackUser: user_not_found is normal for deactivated/deleted users
  and stale references from old messages. Already returns null; downgrade
  the log to warn.

- inviteToChannel: not_in_channel (bot isn't a member yet), channel_not_found,
  is_archived, user_is_restricted, user_is_ultra_restricted, user_disabled
  are all expected Slack states. Already returns { ok: false, error }; the
  caller decides what to do. Downgrade log to warn for these specific codes.

Other failure paths in the file still log at error for unknown failures.
Follows the logger.error vs logger.warn convention added in the JSDoc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley enabled auto-merge (squash) April 30, 2026 12:12
@bokelley bokelley merged commit 262caba into main Apr 30, 2026
13 checks passed
@bokelley bokelley deleted the bokelley/quiet-slack-expected-errors branch April 30, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant