Skip to content

Conversation

@aadamgough
Copy link
Collaborator

Summary

Fix validation schmea

Type of Change

  • Bug fix

Testing

How has this been tested? What should reviewers focus on?

Checklist

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

@vercel
Copy link

vercel bot commented Nov 10, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 10, 2025 8:13pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 10, 2025

Greptile Overview

Greptile Summary

Fixed validation schema mismatch in the copilot training API endpoint. The previous schema validated operations with fields (type, data, timestamp, metadata) that didn't match the actual data structure being sent from the training modal.

The corrected schema now properly validates:

  • operation_type - The type of edit operation (add, edit, delete, insert_into_subflow, extract_from_subflow)
  • block_id - The ID of the block being operated on
  • params - Optional parameters for the operation

This aligns with the EditOperation interface defined in compute-edit-sequence.ts:3-18 and the actual data being sent from training-modal.tsx:130.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a validation bug by correcting the schema to match actual data
  • The change correctly aligns the Zod validation schema with the actual EditOperation interface and data being sent. The fix is straightforward, well-scoped, and resolves a validation mismatch that would have caused 400 errors
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/api/copilot/training/route.ts 5/5 Fixed validation schema to match actual operation data structure (operation_type, block_id, params)

Sequence Diagram

sequenceDiagram
    participant Client as Training Modal
    participant API as /api/copilot/training
    participant Zod as Schema Validator
    participant Indexer as Agent Indexer

    Client->>API: POST training data
    Note over Client,API: { title, prompt, input, output, operations }
    
    API->>Zod: Validate request body
    Note over Zod: TrainingDataSchema checks:<br/>- operations array<br/>- operation_type (string)<br/>- block_id (string)<br/>- params (optional)
    
    alt Invalid Schema
        Zod-->>API: Validation error
        API-->>Client: 400 Bad Request
    else Valid Schema
        Zod-->>API: Validated data
        API->>Indexer: POST /operations/add
        Note over API,Indexer: Forwarded with x-api-key header
        
        alt Indexer Success
            Indexer-->>API: 200 OK
            API-->>Client: Success response
        else Indexer Error
            Indexer-->>API: Error status
            API-->>Client: Forward error status
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@aadamgough aadamgough merged commit 0d4d953 into staging Nov 10, 2025
9 checks passed
waleedlatif1 pushed a commit that referenced this pull request Nov 10, 2025
@waleedlatif1 waleedlatif1 deleted the fix/copilot-train branch November 11, 2025 02:21
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
@waleedlatif1 waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
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.

2 participants