Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Should not die on editing deployed webhook.

Type of Change

  • Bug fix

Testing

Tested manually

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 Jan 17, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 17, 2026 3:45am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 17, 2026

Greptile Summary

This PR completes the fix for webhook-related crashes by removing webhook preservation logic from workflow editing operations and adding stricter parameter validation.

  • Removed webhook preservation code from saveWorkflowToNormalizedTables() that was attempting to preserve and re-insert webhooks during workflow saves
  • Removed webhook preservation code from handleWorkflowOperationTx() for the replace-state operation
  • Added Array.isArray() check in edit_workflow tool to properly validate the operations parameter before checking its length

The webhook preservation logic was causing the application to crash when editing deployed webhooks. This is a continuation of commit df8dd05 which started removing this problematic logic. Webhooks are properly managed through their CASCADE DELETE relationships with workflowId and deploymentVersionId in the database schema, so manual preservation during workflow edits is unnecessary and error-prone.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes remove problematic code that was causing crashes and add better parameter validation. The webhook preservation logic was unnecessary since webhooks have proper CASCADE DELETE relationships in the database schema. The array validation improvement prevents potential runtime errors. All changes are deletions of error-prone code or simple validation improvements.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts Added stricter type validation for operations parameter to ensure it's an array before checking length
apps/sim/lib/workflows/persistence/utils.ts Removed webhook preservation logic that was causing issues with deployed webhooks (continued from previous commit)
apps/sim/socket/database/operations.ts Removed webhook preservation logic from replace-state operation (continued from previous commit)

Sequence Diagram

sequenceDiagram
    participant Client
    participant EditWorkflow as edit_workflow Tool
    participant WorkflowPersistence as persistence/utils
    participant SocketOps as socket/operations
    participant DB as Database

    Client->>EditWorkflow: execute({operations, workflowId})
    
    Note over EditWorkflow: Validate operations is array<br/>and not empty
    
    alt operations not array or empty
        EditWorkflow-->>Client: Error: operations required and must be array
    end
    
    EditWorkflow->>WorkflowPersistence: saveWorkflowToNormalizedTables()
    
    Note over WorkflowPersistence: Start transaction
    
    WorkflowPersistence->>DB: DELETE workflowBlocks
    WorkflowPersistence->>DB: DELETE workflowEdges
    WorkflowPersistence->>DB: DELETE workflowSubflows
    
    Note over WorkflowPersistence: No webhook preservation<br/>(removed in this PR)
    
    WorkflowPersistence->>DB: INSERT new blocks
    WorkflowPersistence->>DB: INSERT new edges
    WorkflowPersistence->>DB: INSERT new subflows
    
    Note over WorkflowPersistence: Commit transaction
    
    WorkflowPersistence-->>EditWorkflow: {success: true}
    
    EditWorkflow->>SocketOps: handleWorkflowOperationTx(replace-state)
    
    Note over SocketOps: Start transaction
    
    SocketOps->>DB: DELETE workflowBlocks
    SocketOps->>DB: DELETE workflowSubflows
    
    Note over SocketOps: No webhook preservation<br/>(removed in this PR)
    
    SocketOps->>DB: INSERT new blocks
    SocketOps->>DB: INSERT new edges
    SocketOps->>DB: INSERT new subflows
    
    Note over SocketOps: Commit transaction
    
    SocketOps-->>EditWorkflow: Success
    EditWorkflow-->>Client: Modified workflow state
Loading

@icecrasher321 icecrasher321 merged commit b146728 into staging Jan 17, 2026
11 checks passed
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