Skip to content

Change Postgres query error logging from error to warn - #118

Merged
owens1127 merged 1 commit into
mainfrom
seer/feat/log-postgres-query-errors-as-warn
Feb 22, 2026
Merged

Change Postgres query error logging from error to warn#118
owens1127 merged 1 commit into
mainfrom
seer/feat/log-postgres-query-errors-as-warn

Conversation

@seer-by-sentry

Copy link
Copy Markdown
Contributor

Fixes API-12. The issue was that: Admin query failures, though gracefully handled by API, are prematurely sent to Sentry by the Postgres query executor.

  • Changed logger.error to logger.warn for QUERY_ERROR in src/integrations/postgres/shared.ts.
  • This adjusts the severity level for logging Postgres query execution errors.

This fix was generated by Seer in Sentry, triggered by Owen. 👁️ Run ID: 10541230

Not quite right? Click here to continue debugging with Seer.

@seer-by-sentry
seer-by-sentry Bot requested a review from owens1127 February 22, 2026 03:16
@barecheck

barecheck Bot commented Feb 22, 2026

Copy link
Copy Markdown

Barecheck - Code coverage report

Total: 92.9%

Your code coverage diff: 0.15% ▴

Uncovered files and lines
FileLines
src/integrations/postgres/shared.ts100, 104-111

@owens1127
owens1127 marked this pull request as ready for review February 22, 2026 03:19
Copilot AI review requested due to automatic review settings February 22, 2026 03:19
@owens1127
owens1127 merged commit 3bf5aed into main Feb 22, 2026
5 checks passed
@owens1127
owens1127 deleted the seer/feat/log-postgres-query-errors-as-warn branch February 22, 2026 03:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the logging level for Postgres query execution errors from error to warn in response to a Sentry issue where admin query failures were being sent to Sentry despite being gracefully handled by the API.

Changes:

  • Modified logging level from logger.error to logger.warn for the QUERY_ERROR event in the Postgres query executor

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const executeTime = Date.now() - startTime
const err = error instanceof Error ? error : new Error(String(error))
logger.error("QUERY_ERROR", err, {
logger.warn("QUERY_ERROR", err, {

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

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

Changing all query errors from error to warn level is too broad and will hide genuine database errors that should be sent to Sentry. This blanket change means that connection failures, permission issues, constraint violations, and other critical database errors will no longer be tracked in Sentry.

The PR description mentions that "Admin query failures, though gracefully handled by API, are prematurely sent to Sentry". Looking at the admin query route (src/routes/admin/query.ts), it catches DatabaseError specifically and handles syntax errors gracefully. However, this is a specific use case where query errors are expected and handled.

A better solution would be to:

  1. Keep logger.error for genuine unexpected errors
  2. For the admin query endpoint specifically, either catch and handle the error before it reaches executeQuery, or add a parameter to executeQuery to control logging level based on whether errors are expected
  3. Alternatively, add context to distinguish between expected errors (like admin query syntax errors) and unexpected errors (connection failures, permission issues, etc.)

This change affects all database operations across the entire application, not just admin queries.

Copilot uses AI. Check for mistakes.
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