Skip to content

feedback schema#2419

Draft
shagun-singh-inkeep wants to merge 3 commits intomainfrom
feedback
Draft

feedback schema#2419
shagun-singh-inkeep wants to merge 3 commits intomainfrom
feedback

Conversation

@shagun-singh-inkeep
Copy link
Collaborator

No description provided.

@vercel
Copy link

vercel bot commented Feb 26, 2026

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

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Feb 26, 2026 9:49pm
agents-docs Ready Ready Preview, Comment Feb 26, 2026 9:49pm
agents-manage-ui Ready Ready Preview, Comment Feb 26, 2026 9:49pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

⚠️ No Changeset found

Latest commit: c5270d9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@shagun-singh-inkeep
Copy link
Collaborator Author

@claude

@claude
Copy link
Contributor

claude bot commented Feb 26, 2026

Claude finished @shagun-singh-inkeep's task in 2m 45s —— View job


Reviewing PR #2419: Feedback Schema

Tasks:

  • Read repository guidelines (CLAUDE.md)
  • Review database schema changes
  • Review API route implementation
  • Check data access layer implementation
  • Verify validation schemas
  • Check for required components (tests, UI, documentation)
  • Provide comprehensive review feedback

Review Summary

This PR adds a feedback system for capturing user feedback on agent conversations and messages. While the core implementation is solid, there are several critical missing components required by the repository guidelines.

⚠️ Critical Issues

1. Missing Database Migrations 🚨

The PR adds a new feedback table to the runtime schema but no migration files were generated. This will break the database when deployed.

Action required:

pnpm db:generate  # Generate migration for the feedback table
pnpm db:migrate   # Apply the migration locally to test

2. Missing Unit Tests 🚨

Per CLAUDE.md requirements, all new features MUST include comprehensive unit tests. This PR has zero tests for:

  • API route handlers (agents-api/src/domains/manage/routes/__tests__/feedback.test.ts)
  • Data access functions (packages/agents-core/src/data-access/runtime/__tests__/feedback.test.ts)

3. Missing UI Components 🚨

The PR only includes a single feedback-dialog.tsx component but lacks:

  • Feedback management UI for viewing/filtering feedback
  • Integration into the agent builder pages
  • Form validation schemas in the UI

4. Missing Documentation 🚨

No documentation was added to /agents-docs/ explaining:

  • How to use the feedback API
  • Integration guide for developers
  • API reference for the new endpoints

5. Missing Changeset 🚨

This change affects published packages (agents-api, agents-core) but lacks a changeset entry. Required for version management.

Action required:

pnpm bump minor --pkg agents-core --pkg agents-api "Add feedback system for capturing user feedback on conversations and messages"

✅ What's Good

Database Schema

  • Well-structured feedback table with proper foreign key constraints
  • Includes cascade delete for conversation cleanup
  • Good indexing on conversation_id and message_id
  • Flexible properties JSONB field for extensibility

API Implementation

  • Proper use of createProtectedRoute with correct permissions
  • CRUD operations follow existing patterns
  • Appropriate authorization checks (view for reads, edit for writes)
  • Good pagination support

Data Access Layer

  • Clean implementation with proper scoping
  • Efficient query patterns
  • Follows established patterns in the codebase

🔍 Additional Observations

Schema Design Considerations

  1. The reasons field is typed as string[] | null - consider standardizing common feedback reasons
  2. The userType distinguishes between 'user' and 'api_key' which is good for tracking feedback sources
  3. No unique constraints on (conversationId, messageId, userId) - allows multiple feedback entries from same user

Security & Authorization

  • Routes correctly use project-scoped permissions
  • Tenant isolation properly enforced
  • Consider adding rate limiting for feedback creation to prevent spam

API Design

  • RESTful endpoints are well-structured
  • Consider adding bulk operations for analytics use cases
  • Missing endpoint to get feedback stats/analytics

📝 Recommendations

Immediate Actions Required (Blocking):

  1. Generate and apply database migrations
  2. Add comprehensive unit tests (minimum 80% coverage)
  3. Create feedback management UI in agents-manage-ui
  4. Add documentation to agents-docs
  5. Create a changeset entry

Future Enhancements (Non-blocking):

  1. Add analytics endpoints for feedback aggregation
  2. Consider webhook events for feedback creation
  3. Add feedback export functionality
  4. Implement feedback sentiment analysis

Sample Test Structure

// agents-api/src/domains/manage/routes/__tests__/feedback.test.ts
import { describe, it, expect, beforeEach } from 'vitest';

describe('Feedback API Routes', () => {
  describe('POST /feedback', () => {
    it('should create feedback with valid data', async () => {
      // Test implementation
    });
    
    it('should validate required fields', async () => {
      // Test validation
    });
    
    it('should enforce project permissions', async () => {
      // Test authorization
    });
  });
  // More test cases...
});

Verdict: This PR cannot be merged in its current state due to missing mandatory components per CLAUDE.md requirements. Please address the critical issues above before proceeding.

Fix missing migrations →

Fix missing tests →

Fix missing UI →

@itoqa
Copy link

itoqa bot commented Feb 26, 2026

Ito Test Report ❌

33 test cases ran. 32 passed, 1 failed.

The Feedback CRUD API introduced in PR #2419 was tested across create, read, update, delete operations, filtering, pagination, input validation, and security scenarios. All core CRUD operations, data validation (enum types, ID patterns, required fields), authentication enforcement, tenant isolation, SQL injection protection, and cascade delete behavior work correctly. One issue was found: the API returns 500 Internal Server Error instead of 400/415 when requests are sent with an incorrect Content-Type header.

✅ Passed (32)
Test Case Summary Timestamp Screenshot
ROUTE-1 GET feedback list returned 200 with 2 items and correct pagination 6:08 ROUTE-1_6-08.png
ROUTE-2 GET feedback by ID returned 200 with correct data 5:59 ROUTE-2_5-59.png
ROUTE-3 POST feedback with all fields returned 201 with correct data 5:35 ROUTE-3_5-35.png
ROUTE-4 POST feedback with custom ID returned 201 with matching ID 5:49 ROUTE-4_5-49.png
ROUTE-5 PATCH feedback returned 200 with updated type/details and changed updatedAt 6:20 ROUTE-5_6-20.png
ROUTE-6 DELETE feedback returned 200 success:true, GET confirms 404 6:34 ROUTE-6_6-34.png
ROUTE-7 GET feedback filtered by messageId returned exactly 2 items with correct filter 8:11 ROUTE-7_8-11.png
ROUTE-8 Pagination works: page1=2, page2=2, page3=1, total=5, pages=3 8:29 ROUTE-8_8-29.png
EDGE-1 GET non-existent feedback ID returned 404 with application/problem+json 9:51 EDGE-1_9-51.png
EDGE-2 PATCH non-existent feedback returned 404 Not Found 10:03 EDGE-2_10-03.png
EDGE-3 DELETE non-existent feedback returned 404 Not Found 10:13 EDGE-3_10-13.png
EDGE-4 List without conversationId returned 400 with ZodError validation 10:49 EDGE-4_10-49.png
EDGE-5 Create with invalid type=neutral returned 400 Bad Request 11:03 EDGE-5_11-03.png
EDGE-6 Create with invalid userType=admin returned 400 Bad Request 11:16 EDGE-6_11-16.png
EDGE-7 Create with reserved ID 'new' returned 400 Bad Request 11:28 EDGE-7_11-28.png
EDGE-8 Create with invalid ID characters returned 400 Bad Request 11:39 EDGE-8_11-39.png
EDGE-9 Create with non-existent conversationId returned 500 (FK violation) 11:53 EDGE-9_11-53.png
EDGE-10 Duplicate feedback ID returns 500 on second create (PK violation) 12:13 EDGE-10_12-13.png
EDGE-11 Empty conversation list returned 200 with data=[] and total=0 8:47 EDGE-11_8-47.png
EDGE-12 Limit=200 returned 400 Bad Request with ZodError max=100 8:58 EDGE-12_8-58.png
EDGE-13 Invalid pagination values (page=0, -1, limit=0) all return 400 9:15 EDGE-13_9-15.png
EDGE-14 Update with empty body {} returns 200 OK, only updatedAt changed 12:34 EDGE-14_12-34.png
EDGE-15 Cascade delete verified: deleting conversation removes all feedback 15:46 EDGE-15_15-46.png
ADV-1 All unauthenticated requests (GET/POST/PATCH/DELETE) return 401 16:26 ADV-1_16-26.png
ADV-2 Cross-tenant request returned 404, tenant isolation enforced 16:40 ADV-2_16-40.png
ADV-3 SQL injection attempts safely rejected or return empty results 26:51 ADV-3_26-51.png
ADV-4 XSS payloads stored/retrieved verbatim as JSON strings 27:12 ADV-4_27-12.png
ADV-5 Malformed JSON on POST/PATCH returns 400 Bad Request 27:28 ADV-5_27-28.png
ADV-6 Mass assignment prevented: extra fields ignored in create 27:44 ADV-6_27-44.png
ADV-7 Oversized strings rejected with ZodError max length validation 28:00 ADV-7_28-00.png
ADV-9 Path traversal attempts return 400 (ResourceIdSchema validation) 28:27 ADV-9_28-27.png
ADV-10 View-only user can GET (200) but POST/PATCH/DELETE return 404 (permission denied) 24:52 ADV-10_24-52.png
❌ Failed (1)
Test Case Summary Timestamp Screenshot
ADV-8 Wrong Content-Type returns 500 instead of expected 400/415 28:20 ADV-8_28-20.png
Wrong Content-Type header returns 500 instead of 400/415 – Failed
  • Where: POST /manage/tenants/{tenantId}/projects/{projectId}/feedback/

  • Steps to reproduce:

    1. Send POST request to the feedback endpoint
    2. Set Content-Type header to application/x-www-form-urlencoded or text/plain
    3. Include valid feedback data in the body
  • What failed: The API returns 500 Internal Server Error instead of the expected 400 Bad Request or 415 Unsupported Media Type. When Content-Type is not application/json, the request body is not parsed, causing all fields to be null/undefined. This triggers a database FK constraint violation on the null conversationId rather than proper content-type validation.

  • Code analysis: Examined agents-api/src/domains/manage/routes/feedback.ts. The route definition at lines 131-136 specifies that it only accepts application/json content type, but there is no middleware to validate Content-Type before body parsing. When a non-JSON Content-Type is sent, the body parsing silently fails and fields become null, which then causes a FK violation at the database level.

  • Relevant code:

    agents-api/src/domains/manage/routes/feedback.ts (lines 120-163)

    app.openapi(
      createProtectedRoute({
        method: 'post',
        path: '/',
        summary: 'Create Feedback',
        description: 'Create a new feedback entry for a conversation or message',
        operationId: 'create-feedback',
        tags: ['Feedback'],
        permission: requireProjectPermission('edit'),
        request: {
          params: TenantProjectParamsSchema,
          body: {
            content: {
              'application/json': {
                schema: FeedbackApiInsertSchema,
              },
            },
          },
        },
        // ...
      }),
      async (c) => {
        const { tenantId, projectId } = c.req.valid('param');
        const body = c.req.valid('json');  // Returns undefined/null when Content-Type is wrong
    
        const created = await createFeedback(runDbClient)({
          ...body,  // Spreads null values
          id: body.id || generateId(),
          tenantId,
          projectId,
        });  // FK violation occurs here due to null conversationId
        // ...
      }
    );
  • Why this is likely a bug: The route explicitly declares it only accepts application/json content type, but when a different Content-Type is sent, instead of returning a 400 or 415 error, the body parsing fails silently and the request proceeds with null values. This causes a database-level FK constraint error (500) instead of proper HTTP content-type validation (400/415). The error message exposes internal database details rather than providing a user-friendly validation error.

  • Introduced by this PR: Yes – this PR added the feedback route (agents-api/src/domains/manage/routes/feedback.ts is a new file introduced in this PR).

  • Timestamp: 28:20

📋 View Recording

Screen Recording

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