Skip to content

Conversation

Weves
Copy link
Contributor

@Weves Weves commented Oct 7, 2025

Description

^

How Has This Been Tested?

Locally

Additional Options

  • [Optional] Override Linear Check

@Weves Weves requested a review from a team as a code owner October 7, 2025 18:12
Copy link

vercel bot commented Oct 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
internal-search Ready Ready Preview Comment Oct 7, 2025 6:18pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

@Weves Weves merged commit c2dbd3f into main Oct 7, 2025
57 of 58 checks passed
@Weves Weves deleted the fix-slack-bot branch October 7, 2025 18:40
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