Skip to content

fix(deployed-chat): include workspace id in deployed chat request#1664

Merged
waleedlatif1 merged 1 commit intostagingfrom
fix/deployed-chat
Oct 16, 2025
Merged

fix(deployed-chat): include workspace id in deployed chat request#1664
waleedlatif1 merged 1 commit intostagingfrom
fix/deployed-chat

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

include workspace id in deployed chat request

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 Oct 16, 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 Oct 16, 2025 11:23pm

@waleedlatif1 waleedlatif1 merged commit 29c7827 into staging Oct 16, 2025
4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/deployed-chat branch October 16, 2025 23:23
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.

Greptile Overview

Summary

Fixed deployed chat requests to include workspaceId when executing workflows, ensuring proper environment variable resolution and logging context.

Key changes:

  • Added workspaceId to workflow query in chat route
  • Updated StreamingResponseOptions interface to accept optional workspaceId
  • Passed workspaceId to createStreamingResponse for workflow execution

Issues found:

  • Line 135 still uses deployment.userId instead of workflowResult[0].workspaceId for file upload context, creating inconsistency

Confidence Score: 3/5

  • This PR is mostly safe but has one critical inconsistency that needs fixing
  • The PR correctly adds workspaceId to workflow execution but misses updating it in the file upload context (line 135), which could lead to files being uploaded with incorrect workspace context
  • Pay close attention to apps/sim/app/api/chat/[identifier]/route.ts - the file upload context needs the same fix

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/api/chat/[identifier]/route.ts 3/5 Added workspaceId to deployed chat workflow execution, but file upload context still uses incorrect deployment.userId
apps/sim/lib/workflows/streaming.ts 5/5 Added workspaceId property to workflow type definition as optional field

Sequence Diagram

sequenceDiagram
    participant Client
    participant ChatAPI as Chat API Route
    participant DB as Database
    participant Streaming as Streaming Module
    participant Execute as Execute Workflow
    
    Client->>ChatAPI: POST /api/chat/[identifier]
    ChatAPI->>DB: Query chat deployment
    ChatAPI->>DB: Query workflow (get workspaceId)
    Note over ChatAPI,DB: NEW: workspaceId added to query
    ChatAPI->>ChatAPI: Process files (uses workspaceId)
    ChatAPI->>Streaming: createStreamingResponse()
    Note over ChatAPI,Streaming: NEW: workspaceId passed in workflow object
    Streaming->>Execute: executeWorkflow(workflow)
    Note over Execute: Uses workspaceId for:<br/>- Environment variables<br/>- Logging session<br/>- Execution context
    Execute-->>Streaming: Execution result
    Streaming-->>ChatAPI: Stream response
    ChatAPI-->>Client: SSE stream
Loading

Additional Comments (1)

  1. apps/sim/app/api/chat/[identifier]/route.ts, line 135 (link)

    logic: inconsistent workspaceId - using deployment.userId here but workflowResult[0].workspaceId on line 153

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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