BUG: auth_test() not wrapped in try-except in fi_slack.py causing bot crash on invalid token

Open
#183 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Open flexus_client_kit/integrations/fi_slack.py and inspect join_channels() around line 708, starting with the auth_test() call and the existing error handling for users_list and conversations_list. Confirm the intended handling in related flexus_simple_bots/karen/karen_bot.py. Done means invalid, expired, or revoked Slack tokens no longer crash the bot and are logged through self.problems_other while the bot exits or continues gracefully.

Written by the indexing model from the issue text.

Description

bug

Error Summary

The auth_test() call in fi_slack.py at line 708 is not wrapped in a try-except block, causing the bot to crash when encountering an invalid, expired, or revoked Slack token.

Stacktrace

The SlackApiError exception propagates up from the auth_test() call and crashes the bot when authentication fails.

Investigation Findings

Root Cause

File: flexus_client_kit/integrations/fi_slack.py
Line: 708
Function: join_channels()

Why: The auth_test() call on line 708 is not wrapped in a try-except block. When the Slack API returns an invalid_auth error (due to invalid/expired/revoked token), the SlackApiError exception propagates up and crashes the bot. This is inconsistent with the error handling pattern used for other Slack API calls in the same method (users_list, conversations_list), which are all wrapped in try-except blocks.

Git Blame
  • Author: Kirill Starkov
  • Commit: fa6ab32
  • Date: 2025-08-21 15:23:31 +0300
  • Message: init
Code Snippet
async def join_channels(self):
    if not self.reactive_slack:
        return
    web_api_client: AsyncWebClient = self.reactive_slack.client
    my_info = await web_api_client.auth_test()  # <-- NO TRY-EXCEPT HERE
    my_user_id = my_info["user_id"]
    logger.info(f"Bot user ID: {my_user_id}")

    try:  # <-- Other API calls ARE wrapped
        users_response = await web_api_client.users_list(limit=5000)
        ...
    except SlackApiError as e:
        logger.exception("Failed to list users")
        self.problems_other.append(...)

Occurrence Data

  • First Seen: 2026-01-27T19:48:00Z
  • Occurrence Count: 1
  • Affected Pods: flexus-pod-bot-karen-20043-rx
  • Affected Namespaces: isolated
  • Build Info:
    • flexus commit: 1c780beb
    • ckit commit: ec1cf8fc

Fix Suggestion

Wrap the auth_test() call (lines 708-710) in a try-except block to gracefully handle authentication failures. The bot should log the error to self.problems_other and continue or exit gracefully, similar to how other Slack API errors are handled. This will prevent the bot from crashing when the Slack token is invalid, expired, or revoked.

Related Files

  • flexus_simple_bots/karen/karen_bot.py

Secondary Issue

The configuration for this specific karen bot instance has an invalid/expired/revoked SLACK_BOT_TOKEN. While the code should handle this gracefully, the token itself needs to be regenerated or reconfigured in the bot's setup.


This issue was automatically created by Diplodocus based on error investigation ID: 697914e04baba41f22973d2a

Dominant language
Python
Stars
6
Forks
2
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from smallcloudai/flexus-client-kit

All issues in smallcloudai/flexus-client-kit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.