Skip to content

Fix github add: catch channel_not_found, always DM caller, rename to 'add'#2

Merged
ewels merged 4 commits intomainfrom
fix/github-add-error-handling
Mar 19, 2026
Merged

Fix github add: catch channel_not_found, always DM caller, rename to 'add'#2
ewels merged 4 commits intomainfrom
fix/github-add-error-handling

Conversation

@ewels
Copy link
Member

@ewels ewels commented Mar 19, 2026

Summary

  • Bug fix: chat.postMessage calls in the GitHub invite flow were failing with channel_not_found when the bot wasn't a member of the channel. The error bubbled to Bolt's generic handler, silently swallowing all feedback after "Looking up X on GitHub..." — even though the GitHub invitations themselves succeeded.
  • DM failsafe: The caller now always receives a DM confirmation after a successful invite, so they're never left wondering whether it worked.
  • Rename: Slash command shortened from /nf-core github add-member to /nf-core github add.

Changes

invite_flow.py

  • invite_and_greet() now accepts a required client keyword arg and wraps every reply() call in _safe_reply() which catches exceptions and returns False
  • New _reply_or_dm() helper deduplicates the reply-then-DM-fallback pattern (used at all 4 error sites)
  • On reply failure for error messages, falls back to DMing the caller via _dm_caller()
  • On success, always DMs the caller a confirmation ("Done! X has been invited...")

add_member.py

  • _warn_missing_github() now catches chat.postMessage failures and falls back to ephemeral respond()
  • Passes client=client to invite_and_greet() to enable DM failsafe

add_member_shortcut.py

  • Wraps the missing-GitHub-username chat.postMessage in try/except with chat_postEphemeral fallback
  • Passes client=client to invite_and_greet()

router.py

  • Dispatch key changed from add-member to add

Docs & tests

  • All references to add-member updated to add across README, CLAUDE.md, docs/, help text, and tests
  • New test classes TestDmFailsafe covering success DMs and channel-reply-failure fallback
  • Shared test helpers (make_slack_client, channel_messages, dm_messages) extracted to tests/helpers.py

Test plan

  • All 360 tests pass
  • ruff check clean
  • mypy --strict clean
  • Manual test: run /nf-core github add octocat and verify channel reply + DM
  • Manual test: run shortcut from a channel the bot isn't in — verify DM fallback

🤖 Generated with Claude Code

ewels and others added 4 commits March 19, 2026 17:55
…'add'

- Wrap channel reply (chat_postMessage) in try/except so
  channel_not_found no longer silently swallows results
- Always DM the caller as a failsafe confirmation after invite
- Fall back to ephemeral response when channel reply fails
- Rename slash command from 'add-member' to 'add'
- Update all docs, help text, and tests
…tilities

- Extract repeated `if not _safe_reply ... _dm_caller` pattern into
  `_reply_or_dm()` helper (was duplicated 4 times in invite_and_greet)
- Make `client` a required parameter in `invite_and_greet()` since all
  callers always provide it
- Move shared test helpers (`make_slack_client`, `channel_messages`,
  `dm_messages`) from both test files into `tests/helpers.py`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ewels ewels merged commit d029439 into main Mar 19, 2026
3 checks passed
@ewels ewels deleted the fix/github-add-error-handling branch March 19, 2026 17:27
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