-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(autolayout): type issue if workflow deployed + remove dead state code #1524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR addresses a type validation error that occurred when auto-layout operations were performed on deployed workflows. The core issue was that UI-only fields like `deploymentStatuses`, `needsRedeployment`, and `dragStartPosition` were being sent to the API along with the persistent workflow state, causing schema validation to fail.The fix involves two complementary changes:
-
Client-side cleanup: In the auto-layout utility (
auto-layout.ts), the code now destructures out UI-only fields before sending the workflow state to the API. This ensures only database-appropriate fields are persisted while maintaining existing data transformation logic for dates and optional fields. -
API schema adjustment: The workflow state API schema (
route.ts) was updated to remove theDeploymentStatusSchemaanddeploymentStatusesfield entirely, acknowledging these as UI-only concerns. ThedeployedAtfield now usesz.coerce.date()to handle string-to-Date conversion gracefully.
This change maintains the architectural separation between transient UI state and persistent database state. The auto-layout feature can now handle deployed workflows without triggering type validation errors, while preserving all existing functionality for date handling and optional field management.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout.ts | 4/5 | Destructures UI-only fields before API persistence to prevent type validation errors |
| apps/sim/app/api/workflows/[id]/state/route.ts | 4/5 | Removes deployment status schema and updates deployedAt field to use date coercion |
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it addresses a specific type validation bug without changing core functionality
- Score reflects focused changes that properly separate UI state from persistent state with clear architectural reasoning
- Pay close attention to the API schema changes to ensure downstream compatibility with existing deployed workflows
Sequence Diagram
sequenceDiagram
participant User
participant Client as "Auto Layout Client"
participant AutoLayoutAPI as "/api/workflows/[id]/autolayout"
participant StateAPI as "/api/workflows/[id]/state"
participant DB as "Database"
participant Store as "Workflow Store"
User->>Client: "Trigger auto layout"
Client->>Store: "Get current workflow state"
Store-->>Client: "blocks, edges, loops, parallels"
Client->>AutoLayoutAPI: "POST layout request with workflow data"
AutoLayoutAPI-->>Client: "layouted blocks with new positions"
Client->>Store: "Update store with new positions"
Store-->>Client: "State updated"
Note over Client: Clean workflow state for persistence
Client->>Client: "Remove UI-only fields (deploymentStatuses, etc.)"
Client->>Client: "Convert null dates to undefined"
Client->>Client: "Sanitize edges handles"
Client->>StateAPI: "PUT cleaned workflow state"
StateAPI->>DB: "Save to normalized tables"
DB-->>StateAPI: "Save confirmation"
StateAPI-->>Client: "Success response"
alt Save fails
Client->>Store: "Revert to original positions"
Store-->>Client: "State reverted"
Client-->>User: "Error: Failed to save positions"
else Save succeeds
Client-->>User: "Auto layout applied successfully"
end
2 files reviewed, no comments
…code (#1524) * fix(autolayout): type issue if workflow deployed * remove dead code hasActiveWebhook field
Summary
Type issue with deployedStatus and deployedAt fields -- if workflow was deployed. This fixes that.
Removed dead workflow state fields
Type of Change
Testing
Tested manually
Checklist