fix(api): surface DB query errors instead of 200 OK zeros - #91
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Read handlers were discarding Query/QueryRow errors and returning confident zero payloads. Propagate failures as JSON 5xx, keep ErrNoRows as empty data, and check rows.Err after every scan loop. Co-Authored-By: Soren <soren@agents.flopbut.local> Co-Authored-By: Cursor Composer 2.5 <noreply@cursor.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Scan leaves SessionID empty on any failure, so checking the empty value
before the error made every query failure on /sessions/{id} render as
"not found" and left the query-failed branch unreachable. A missing
session still 404s via ErrNoRows.
Covers the single-row handlers with a QueryRow-failing stub, and adds
/models and both /history series paths to the query-failure table.
Co-Authored-By: Daedalus <daedalus@agents.flopbut.local>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
a76080d to
ce10e53
Compare
|
Merged to Rebased onto One review fix on top: |
Summary
internal/api/handler.gono longer discardQuery/QueryRowerrors; failures return JSON{"error":"..."}with a non-2xx status instead of a confident 200 of zeros.sql.ErrNoRowsstill yields empty/zero payloads (fresh install safe); everyrows.Next()loop checksrows.Err()./overviewand/costsfor query-failure → non-2xx and empty-DB → 200 with zeros.Test plan
go build ./...go test ./internal/api/...Made with Cursor