Skip to content

fix(copilot): only accept feedback on the caller's own chat - #10429

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/copilot-feedback-chat-ownership
Nov 26, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/copilot-feedback-chat-ownership

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • POST /api/copilot/feedback inserted a copilot_feedback row for whatever chatId the caller sent, with no check that the chat was theirs
  • Moved it onto an authorized chat use case (submitChatFeedback, mothership.chats.submit_feedback, session only, read / member) that resolves the chat through resolveOwnedChatContext, the same funnel set-effort uses
  • A foreign, deleted, or unknown chat now answers the same 404 Chat not found and stores nothing; organization assistant chats keep working for their owner through the organization branch of defineAuthorizedChatUseCase
  • Route is now a thin defineInternalJsonRoute adapter; PostHog capture moved to onSuccess
  • Contract response trimmed to { success, feedbackId } (the only client, useSubmitCopilotFeedback, reads neither message nor metadata)
  • GET on the same route already filters by the caller's userId; left unchanged

Type of Change

  • Bug fix

Testing

  • New submit-feedback.integration.ts drives the real POST handler against PostgreSQL: owner succeeds on a workspace chat and an organization chat; a workspace member gets the same 404 for the owner's workspace chat, the owner's org chat, and an unknown id, with no rows written
  • Red on the pre-fix route (foreign chat returned 200 and stored the row), green after
  • route.test.ts, biome on changed files, check:api-validation:strict, check:source-conventions, check:boundaries, check:permission-group-enforcement, check:comment-hygiene locally; type-check and the full audit/test gate in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

POST /api/copilot/feedback stored a row for any chatId the caller sent.
It now runs through an authorized chat use case that resolves the chat
with resolveOwnedChatContext, so a foreign or unknown chat answers the
same 404 and nothing is stored. Organization assistant chats keep working
for their owner.
@vercel

vercel Bot commented Nov 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 26, 2026 7:15pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Feedback submissions now check that the caller owns the chat before saving a row.

  • Feedback submissions now attach only to chats their caller owns.

No actionable issues were found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Feedback request] --> B[Check session]
  B --> C[Find live chat owned by caller]
  C -->|Missing or foreign| D[404 Chat not found]
  C -->|Workspace chat| E[Check workspace access]
  C -->|Organization chat| F[Check organization membership]
  E --> G[Save feedback]
  F --> G
  G --> H[Return success and feedbackId]
Loading

Reviews (1) · Last reviewed commit: "fix(copilot): only accept feedback on th..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 1394733 into staging Nov 26, 2026
154 of 156 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/copilot-feedback-chat-ownership branch November 26, 2026 21:31

This branch was previously deployed

1 inactive deployment
Preview — 1db005e0 Deployed Nov 26, 2026 by vercel[bot]
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.

1 participant