Skip to content

Conversation

@ArcaEge
Copy link
Collaborator

@ArcaEge ArcaEge commented Dec 1, 2025

No description provided.

@ArcaEge ArcaEge merged commit 393c586 into main Dec 1, 2025
2 checks passed
Comment on lines +18 to +25
const [{ devlogCount }] = (await db
.select({
devlogCount: sql`COALESCE(COUNT(${devlog.id}), 0)`
})
.from(user)
.leftJoin(devlog, eq(devlog.userId, user.id))
.where(eq(user.id, 1))
.groupBy(user.id)) ?? [{ devlogCount: 0 }];
Copy link

Choose a reason for hiding this comment

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

Bug: Devlog count query hardcodes user.id to 1 instead of using dynamic id from URL, showing incorrect data.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The devlog count query at src/routes/dashboard/admin/admin/users/[id]/+page.server.ts line 24 uses a hardcoded user.id, 1 in its where clause instead of the dynamically parsed id from the URL parameter. This causes every user's admin page to display the devlog count for user ID 1, regardless of the user being viewed, leading to incorrect data being presented to administrators.

💡 Suggested Fix

Replace .where(eq(user.id, 1)) with .where(eq(user.id, id)) in the devlog count query at src/routes/dashboard/admin/admin/users/[id]/+page.server.ts line 24.

🤖 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/dashboard/admin/admin/users/[id]/+page.server.ts#L18-L25

Potential issue: The devlog count query at
`src/routes/dashboard/admin/admin/users/[id]/+page.server.ts` line 24 uses a hardcoded
`user.id, 1` in its `where` clause instead of the dynamically parsed `id` from the URL
parameter. This causes every user's admin page to display the devlog count for user ID
1, regardless of the user being viewed, leading to incorrect data being presented to
administrators.

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

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