-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: slack bot creation #5637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: slack bot creation #5637
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR fixes a validation issue in the Slack bot creation flow by updating the `validate_user_token` function to properly handle empty strings. The change modifies the early return condition from checking only for `None` values to also checking for falsy values like empty strings.The function is part of the Slack token validation system in /backend/onyx/server/manage/validate_tokens.py
, which validates bot tokens, app tokens, and user tokens for Slack integration. Since user tokens are optional in the Slack bot setup, the function should accept both None
and empty string values as valid inputs without attempting further validation.
The modification changes the condition from if user_token is None:
to if user_token is None or not user_token:
. This means any falsy string value (empty strings, whitespace-only strings, etc.) will now bypass the prefix validation that would otherwise fail, treating them as valid optional inputs just like None
values.
This change aligns with the business logic that user OAuth tokens are truly optional in Slack bot configurations, regardless of whether the absence is represented as None
or an empty string from form submissions or API calls.
Important Files Changed
Changed Files
Filename | Score | Overview |
---|---|---|
backend/onyx/server/manage/validate_tokens.py | 4/5 | Updated validate_user_token function to handle empty strings as valid optional inputs |
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it only makes the validation more permissive for optional fields
- Score reflects a simple, well-targeted fix that addresses a common edge case in form handling
- No files require special attention as the change is straightforward and isolated
Sequence Diagram
sequenceDiagram
participant User
participant API as "Onyx API"
participant SlackAPI as "Slack API"
User->>API: "Create/Configure Slack Bot"
alt Bot Token Validation
API->>API: "validate_bot_token(bot_token)"
API->>SlackAPI: "POST /api/auth.test with Bearer token"
SlackAPI-->>API: "Response with ok status"
alt Invalid Token
API->>User: "HTTPException 400: Invalid bot token"
else Valid Token
API->>API: "Continue validation"
end
end
alt App Token Validation
API->>API: "validate_app_token(app_token)"
API->>SlackAPI: "POST /api/apps.connections.open with Bearer token"
SlackAPI-->>API: "Response with ok status"
alt Invalid Token
API->>User: "HTTPException 400: Invalid app token"
else Valid Token
API->>API: "Continue validation"
end
end
alt User Token Validation (Optional)
API->>API: "validate_user_token(user_token)"
alt Token Present
API->>API: "Check token format (xoxp- prefix)"
alt Invalid Format
API->>User: "HTTPException 400: Invalid user token format"
else Valid Format
API->>SlackAPI: "POST /api/auth.test with Bearer token"
SlackAPI-->>API: "Response with ok status"
alt Invalid Token
API->>User: "HTTPException 400: Invalid user token"
else Valid Token
API->>API: "Validation complete"
end
end
else No Token
API->>API: "Skip validation (optional)"
end
end
alt All Validations Pass
API->>User: "Slack bot configured successfully"
end
1 file reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
Description
^
How Has This Been Tested?
Locally
Additional Options