feat(feedback-records): add submission_id for grouped submissions and idempotent ingestion#39
Open
feat(feedback-records): add submission_id for grouped submissions and idempotent ingestion#39
Conversation
… idempotent ingestion - Add migration 003: submission_id column, indexes, unique (tenant_id, submission_id, field_id) where submission_id IS NOT NULL - Add submission_id to FeedbackRecord, CreateFeedbackRecordRequest, ListFeedbackRecordsFilters - Repository: CRUD and list filter by submission_id; map unique violation to ConflictError - Handler: respond 409 Conflict on duplicate (tenant_id, submission_id, field_id) - OpenAPI: document submission_id on create, list, and response; document 409 - Add RespondConflict and ConflictError - Integration tests: submission_id create/list and unique constraint 409 Co-authored-by: Cursor <cursoragent@cursor.com>
✱ Stainless preview buildsThis PR will update the Edit this comment to update it. It will appear in the SDK's changelogs. ✅ hub-typescript studio · code · diff
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a
submission_idfield tofeedback_recordsso that records belonging to one logical feedback submission can be grouped. This supports use cases like multi-field ingestion from a single event (e.g. Stripe cancellation: reason, comment, date) and simplifies:GET /v1/feedback-records?submission_id=...Changes:
003_add_feedback_records_submission_id.sql: adds nullablesubmission_id(VARCHAR 255), indexes for filtering, and partial unique index on(tenant_id, submission_id, field_id)wheresubmission_id IS NOT NULL(one value per field per submission; backward compatible for rows without submission_id).FeedbackRecordand create/list request types includesubmission_id; list filters supportsubmission_id.submission_id; Create maps PostgreSQL unique violation (23505) tohuberrors.ConflictError.submission_id; FeedbackRecordData includessubmission_id; 409 response documented for create.TestFeedbackRecordsSubmissionID(create with submission_id, list by submission_id),TestFeedbackRecordsSubmissionIDUniqueConstraint(duplicate create returns 409).Existing integrations remain compatible:
submission_idis optional on create; records without it are valid and the unique constraint does not apply to NULL.Example – create with submission_id:
Example – list by submission_id:
Example – duplicate create (same tenant_id, submission_id, field_id): returns
409 Conflictwith body describing the conflict.How should this be tested?
make test-unit(passes).make docker-up), thenmake tests. Covers create without/with submission_id, list by submission_id, and duplicate create → 409.make build,make fmt,make lint(all pass).make init-dbto apply migration;make migrate-validateto validate migration files.tenant_id,submission_id, andfield_id; second request should return 409. List with?submission_id=...returns only records with that submission_id.Checklist
Required
make buildmake tests(integration tests require Postgres; unit tests and build pass)make fmtandmake lint; no new warningsgit pull origin mainmigrations/with goose annotations and ranmake migrate-validateAppreciated
make testsor API contract workflow)docs/if changes were necessarymake tests-coveragefor meaningful logic changes