Skip to content

Commit

Permalink
simplify slack check
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Feb 19, 2025
1 parent 601a425 commit a473f5b
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions backend/onyx/connectors/slack/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,6 @@ def load_from_checkpoint(
return checkpoint

def validate_connector_settings(self) -> None:
"""
Validate that we can connect to Slack and have correct scopes to list conversations.
Raises:
ConnectorMissingCredentialError: If no Slack client is loaded (missing credentials).
CredentialExpiredError: If Slack reports "invalid_auth" or "not_authed".
InsufficientPermissionsError: If Slack reports "missing_scope" or any scope issue.
ConnectorValidationError: Any other type of Slack error or a config mismatch.
"""
if self.client is None:
raise ConnectorMissingCredentialError("Slack credentials not loaded.")

Expand All @@ -701,13 +693,7 @@ def validate_connector_settings(self) -> None:

except SlackApiError as e:
slack_error = e.response.get("error", "")
# Slack typically returns codes like "invalid_auth", "not_authed", "missing_scope"
# Refer to Slack docs for all error codes: https://api.slack.com/methods/auth.test
if slack_error in ("invalid_auth", "not_authed"):
raise CredentialExpiredError(
f"Invalid or expired Slack bot token ({slack_error})."
)
elif slack_error == "missing_scope":
if slack_error == "missing_scope":
# The needed scope is typically "channels:read" or "groups:read"
# for viewing channels. The error message might also contain the
# specific scope needed vs. provided.
Expand Down

0 comments on commit a473f5b

Please sign in to comment.