Skip to content

[codex] fix(handlers): detect not-found with errors.Is#59

Draft
prettyboyvic wants to merge 2 commits into
Grainlify:mainfrom
prettyboyvic:fix/pgx-errnorows-detection
Draft

[codex] fix(handlers): detect not-found with errors.Is#59
prettyboyvic wants to merge 2 commits into
Grainlify:mainfrom
prettyboyvic:fix/pgx-errnorows-detection

Conversation

@prettyboyvic

@prettyboyvic prettyboyvic commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • replace fragile ecosystem lookup string comparisons with a shared errors.Is(err, pgx.ErrNoRows) mapper
  • apply wrapped-error-safe detection to both ecosystem GetByID handlers and the remaining public project lookup
  • cover unwrapped, wrapped, generic, and nil lookup failures with focused unit tests

Why

Matching database error text can misclassify a real not-found response as a 500 when pgx errors are wrapped or their wording changes. Stable sentinel matching preserves the API contract across wrapped error chains.

Security notes

  • only pgx.ErrNoRows maps to HTTP 404
  • all other failures map to a stable HTTP 500 code
  • raw database error text is never returned to clients

Validation

  • go test ./internal/handlers/... — passed
  • audited internal/handlers/** — no string or direct-equality pgx.ErrNoRows checks remain
  • git diff --check — passed

Closes #31

@prettyboyvic prettyboyvic changed the title [codex] fix handlers ErrNoRows detection [codex] fix(handlers): detect not-found with errors.Is Jun 21, 2026
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.

Use errors.Is(err, pgx.ErrNoRows) instead of string comparison in ecosystems_public.go and admin_ecosystems.go

1 participant