Repository navigation
fix(purchases): distinguish not-found from DB errors in GetExecutionByID - #1108
Conversation
…yID (#976) GetExecutionByID previously returned (nil, error) for a missing row, which caused getPurchaseDetails to map every DB failure - including real connection errors - to a 404 ClientError. Callers had no way to distinguish a missing row from an infrastructure failure. Change GetExecutionByID to return (nil, nil) when no row matches, following the sentinel pattern used by other store methods. Update getPurchaseDetails to return a 500 on real DB errors and a 404 only on the nil-execution sentinel. Update tests to mock the new contract. Closes #976
|
Warning Review limit reached
More reviews will be available in 36 minutes and 3 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review Generated by Claude Code |
|
🧠 Learnings used✅ Action performedReview finished.
|
|
@coderabbitai review Generated by Claude Code |
|
🧠 Learnings used✅ Action performedReview finished.
|
Summary
Closes #976
GetExecutionByIDpreviously returned(nil, error)for a missing row. This causedgetPurchaseDetailsto map every DB failure - including real connection errors and timeouts - to a 404 ClientError, hiding infrastructure failures from operators and preventing callers from distinguishing "not found" from "the database is down."GetExecutionByIDnow returns(nil, nil)when no row matchesexecutionID, following the sentinel pattern used by other store methods in this package.getPurchaseDetailsnow returns a 500 on real DB errors (preserving the wrapped error for operator visibility) and a 404 ClientError only on the(nil, nil)sentinel.TestHandler_getPurchaseDetails_NilExecutiontest already covered the(nil, nil)path and continues to pass unchanged.Test plan
go test ./internal/api/...- allTestHandler_getPurchaseDetails_*passgo test ./internal/config/...- passesgo test ./...- no new failures introduced (two pre-existing failures ininternal/authandinternal/serverare unrelated to this change)Generated by Claude Code