Skip to content

V0.2.2 testing#2

Merged
CodeMeAPixel merged 2 commits intomasterfrom
v0.2.2-testing
Feb 28, 2026
Merged

V0.2.2 testing#2
CodeMeAPixel merged 2 commits intomasterfrom
v0.2.2-testing

Conversation

@CodeMeAPixel
Copy link
Contributor

No description provided.

@CodeMeAPixel CodeMeAPixel merged commit d7c745f into master Feb 28, 2026
3 of 4 checks passed
@github-actions
Copy link

📊 Code Coverage Report

Total Coverage: 1.8%

View Full Report

Comment on lines +47 to +54
h.db.Pool.QueryRow(ctx,
`SELECT COUNT(*) FROM servers WHERE "ownerId" = $1`, userID).Scan(&totalServers)
h.db.Pool.QueryRow(ctx,
`SELECT COUNT(*) FROM servers WHERE "ownerId" = $1 AND status = 'RUNNING'`, userID).Scan(&onlineServers)
h.db.Pool.QueryRow(ctx,
`SELECT COUNT(*) FROM servers WHERE "ownerId" = $1 AND status = 'OFFLINE'`, userID).Scan(&offlineServers)
h.db.Pool.QueryRow(ctx,
`SELECT COUNT(*) FROM servers WHERE "ownerId" = $1 AND "isSuspended" = true`, userID).Scan(&suspendedServers)
Copy link

Choose a reason for hiding this comment

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

Bug: The GetDashboardStats handler ignores errors from QueryRow().Scan() calls, causing it to return a 200 OK response with misleading zero-value statistics if a database query fails.
Severity: MEDIUM

Suggested Fix

Check the error returned by each h.db.Pool.QueryRow(...).Scan(...) call in the GetDashboardStats handler. If the error is not nil, return an HTTP 500 Internal Server Error response, similar to the pattern used in the GetUserAccount handler.

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: internal/handlers/dashboard.go#L47-L54

Potential issue: In the `GetDashboardStats` handler, multiple database calls using
`QueryRow().Scan()` do not have error handling. If a query fails, for instance due to a
temporary database connection issue, the error is silently ignored. As a result, the
associated variables retain their default zero values. The handler then returns an HTTP
200 OK response with misleading statistics (e.g., zero servers, zero balance), rather
than returning an appropriate server error. This behavior is inconsistent with other
handlers like `GetUserAccount` which correctly handle database errors.

Did we get this right? 👍 / 👎 to inform future reviews.

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