Skip to content

fix(api): return postgres query details#213

Open
deodad wants to merge 1 commit into
mainfrom
dad/query-error-messages
Open

fix(api): return postgres query details#213
deodad wants to merge 1 commit into
mainfrom
dad/query-error-messages

Conversation

@deodad

@deodad deodad commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Return useful PostgreSQL query errors from /query instead of db error.

Motivation

PostgreSQL exposes the real failure through tokio_postgres::DbError, but the API was formatting the outer error after anyhow flattened it to db error. That made bad SQL hard to debug from API responses.

Changes

  • Extract DbError fields in src/service/mod.rs before formatting query failures.
  • Return sanitized message, detail, hint, and position when Postgres provides them.
  • Add an API regression test in tests/api_live_test.rs for a missing column query.

Testing

  • cargo fmt --check
  • cargo check
  • cargo test test_sanitize
  • DATABASE_URL=postgresql://tidx:tidx@localhost:5433/tidx cargo test test_query_returns_postgres_error_message

@deodad deodad marked this pull request as ready for review June 1, 2026 10:06
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