fix: resolve feedback submission failure from composite key conflict#1306
fix: resolve feedback submission failure from composite key conflict#1306EItanya merged 1 commit intokagent-dev:mainfrom
Conversation
Remove invalid `primaryKey` tag from `UserID` field in the `Feedback` struct. The embedded `gorm.Model` already provides `ID` as the primary key, so marking `UserID` as a second primary key created a composite key that caused upsert failures when submitting feedback. Also change `StoreFeedback()` to use `db.Create()` instead of the generic `save()` helper (which performs an upsert via ON CONFLICT), since feedback records should always be inserted as new rows. Fixes kagent-dev#1170 Signed-off-by: opspawn <opspawn@users.noreply.github.com> Signed-off-by: OpSpawn Agent <agent@opspawn.com>
There was a problem hiding this comment.
Pull request overview
Fixes feedback submission failures caused by GORM upsert (ON CONFLICT) behavior interacting with an invalid composite primary key definition on the Feedback model.
Changes:
- Updates the
Feedbackmodel schema to removeprimaryKeyfromUserIDand make it a regular indexed column. - Changes
StoreFeedback()to insert viadb.Create()instead of using the generic upsert-basedsave()helper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| go/pkg/database/models.go | Adjusts Feedback.UserID GORM tags to avoid an invalid composite primary key with gorm.Model.ID. |
| go/internal/database/client.go | Switches feedback persistence from upsert to insert-only to avoid ON CONFLICT failures for new feedback rows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Gentle ping — this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance. This fixes the feedback submission 500 error caused by a composite key conflict in the database layer. |
2 similar comments
|
Gentle ping — this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance. This fixes the feedback submission 500 error caused by a composite key conflict in the database layer. |
|
Gentle ping — this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance. This fixes the feedback submission 500 error caused by a composite key conflict in the database layer. |
|
Gentle ping — this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance. This fixes the feedback submission 500 error caused by a composite key conflict. |
1 similar comment
|
Gentle ping — this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance. This fixes the feedback submission 500 error caused by a composite key conflict. |
|
Gentle ping - this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance. |
Summary
Fixes #1170
The
Feedbackstruct marks bothgorm.Model.IDandUserIDasprimaryKey, creating an invalid composite primary key. WhenStoreFeedback()calls the genericsave()helper (which performs an upsert viaON CONFLICT), the composite key lookup fails for new feedback submissions.Changes
go/pkg/database/models.go: RemoveprimaryKeytag fromUserIDfield in theFeedbackstruct. The embeddedgorm.Modelalready providesIDas the sole primary key.UserIDis now a regular indexed column (not null;index).go/internal/database/client.go: ChangeStoreFeedback()to usedb.Create()directly instead of the genericsave()helper, since feedback records should always be inserted as new rows rather than upserted.How I tested
go vet ./...— passesgofmt— no formatting issuesinternal/databaseandinternal/httpserver/handlers— all passSigned-off-by: opspawn opspawn@users.noreply.github.com