Skip to content

fix(api): map feedback and survey constraint violations to 400 instead of 500 - #1110

Merged
ericfitz merged 4 commits into
mainfrom
fix/1099-feedback-constraint-400
Oct 18, 2026
Merged

ericfitz merged 4 commits into
mainfrom
fix/1099-feedback-constraint-400

Conversation

@ericfitz

Copy link
Copy Markdown
Owner

Summary

  • Feedback POSTs: mapDBError maps dberrors.ErrConstraint (which wraps duplicate and foreign-key errors) to 400 invalid_input with a fixed message, so driver text stays out of the response. The detail is logged at Warn.
  • POST /admin/surveys and PUT /admin/surveys/{id}: a constraint violation that isn't a duplicate now returns 400 instead of 500. The PUT case was found by the Fixes (B) sweep.
  • 409 isn't documented for the feedback POSTs, so StoreErrorToRequestError isn't reused.

Test plan

  • api/feedback_map_db_error_test.go failed before the fix and passes after it
  • make verify
  • Combined integration run: 97 passed, 0 failed
  • Oracle review: APPROVED

Fixes #1099

🤖 Generated with Claude Code

https://claude.ai/code/session_015szS68rpMLaq712AFsbMfr

ericfitz and others added 4 commits October 17, 2026 20:26
mapDBError now maps dberrors.ErrConstraint (and ErrDuplicate/ErrForeignKey,
which wrap it) to 400 invalid_input with a fixed message; the raw driver
text stays out of the response. 409 is not documented for the feedback
POSTs, so StoreErrorToRequestError is not reused.

Fixes #1099

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
POST /admin/surveys and PUT /admin/surveys/{id} returned 500 on a
non-duplicate constraint violation (e.g. a status longer than its column
passes the spec's maxLength). Map ErrConstraint to 400 invalid_input after
the duplicate check. Also tidy the mapDBError SEM marker and test setup.

Fixes #1099

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #1099

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015szS68rpMLaq712AFsbMfr
@ericfitz
ericfitz merged commit 7f98676 into main Oct 18, 2026
18 checks passed
@ericfitz
ericfitz deleted the fix/1099-feedback-constraint-400 branch October 18, 2026 03:33
ericfitz-version-bump Bot added a commit that referenced this pull request Oct 18, 2026
Folds 1 merged commit(s):
- 7f98676 fix(api): map feedback and survey constraint violations to 400 instead of 500 (#1110)
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.

fix(api): map feedback constraint violations to 4xx instead of 500

1 participant