Skip to content

fix: resolve feedback submission failure from composite key conflict#1306

Merged
EItanya merged 1 commit intokagent-dev:mainfrom
opspawn:fix/feedback-submission
Feb 15, 2026
Merged

fix: resolve feedback submission failure from composite key conflict#1306
EItanya merged 1 commit intokagent-dev:mainfrom
opspawn:fix/feedback-submission

Conversation

@opspawn
Copy link
Contributor

@opspawn opspawn commented Feb 15, 2026

Summary

Fixes #1170

The Feedback struct marks both gorm.Model.ID and UserID as primaryKey, creating an invalid composite primary key. When StoreFeedback() calls the generic save() helper (which performs an upsert via ON CONFLICT), the composite key lookup fails for new feedback submissions.

Changes

  • go/pkg/database/models.go: Remove primaryKey tag from UserID field in the Feedback struct. The embedded gorm.Model already provides ID as the sole primary key. UserID is now a regular indexed column (not null;index).
  • go/internal/database/client.go: Change StoreFeedback() to use db.Create() directly instead of the generic save() helper, since feedback records should always be inserted as new rows rather than upserted.

How I tested

  • go vet ./... — passes
  • gofmt — no formatting issues
  • Existing test suites for internal/database and internal/httpserver/handlers — all pass

Signed-off-by: opspawn opspawn@users.noreply.github.com

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>
Copilot AI review requested due to automatic review settings February 15, 2026 04:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Feedback model schema to remove primaryKey from UserID and make it a regular indexed column.
  • Changes StoreFeedback() to insert via db.Create() instead of using the generic upsert-based save() 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.

@EItanya EItanya merged commit cbc8d57 into kagent-dev:main Feb 15, 2026
21 of 22 checks passed
@fl-sean03
Copy link
Contributor

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
@fl-sean03
Copy link
Contributor

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.

@fl-sean03
Copy link
Contributor

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.

@fl-sean03
Copy link
Contributor

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
@fl-sean03
Copy link
Contributor

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.

@fl-sean03
Copy link
Contributor

Gentle ping - this has EItanya approval and CI is passing. Would appreciate a second review when anyone has a chance.

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.

providing feedback through the UI fails

4 participants