Skip to content

Conversation

@ArcaEge
Copy link
Collaborator

@ArcaEge ArcaEge commented Dec 4, 2025

No description provided.

@ArcaEge ArcaEge merged commit 6559df2 into main Dec 4, 2025
2 checks passed
Comment on lines +109 to +112
const username =
slackProfile['profile']['display_name'] !== ''
? slackProfile['profile']['display_name']
: slackProfile['profile']['real_name'];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The username can be null, undefined, or '' if both display_name and real_name are invalid from Slack API, violating the NOT NULL database constraint for user name.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The code attempts to assign a username based on slackProfile['profile']['display_name'] or slackProfile['profile']['real_name']. If display_name is an empty string ('') and real_name is undefined, null, or '' (as per Slack API documentation), the username variable will receive an invalid value. This invalid value is then used directly in database INSERT or UPDATE operations for the name field, which is defined as NOT NULL. This will cause a database constraint violation, leading to a 500 error during the authentication flow.

💡 Suggested Fix

Before using slackProfile['profile']['real_name'], validate it to ensure it's not undefined, null, or ''. Provide a default fallback value (e.g., 'Anonymous User') if both display_name and real_name are invalid to satisfy the NOT NULL database constraint.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/routes/auth/callback/+server.ts#L109-L112

Potential issue: The code attempts to assign a `username` based on
`slackProfile['profile']['display_name']` or `slackProfile['profile']['real_name']`. If
`display_name` is an empty string ('') and `real_name` is `undefined`, `null`, or '' (as
per Slack API documentation), the `username` variable will receive an invalid value.
This invalid value is then used directly in database `INSERT` or `UPDATE` operations for
the `name` field, which is defined as `NOT NULL`. This will cause a database constraint
violation, leading to a 500 error during the authentication flow.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 5628196

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.

2 participants