Workflow persistence error#3938
Conversation
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 079b113. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes a workflow persistence error caused by SQLite's 999-bound-parameter limit by chunking
Confidence Score: 5/5Safe to merge — the chunking fix is correct and all remaining findings are cosmetic indentation issues The core logic (CHUNK_SIZE=50 batched inserts inside an existing transaction) is sound and correctly addresses the SQLite 999-parameter limit. The only open issues are two P2 indentation regressions in apps/sim/lib/workflows/persistence/utils.ts — indentation regressions at lines 822–826 and 900 in Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[saveWorkflowToNormalizedTables] --> B[Delete existing blocks/edges/subflows]
B --> C{blocks.length > 0?}
C -- Yes --> D[Chunk blockInserts into groups of 50]
D --> E[INSERT each chunk into workflowBlocks]
C -- No --> F{edges.length > 0?}
E --> F
F -- Yes --> G[Chunk edgeInserts into groups of 50]
G --> H[INSERT each chunk into workflowEdges]
F -- No --> I[Build subflowInserts]
H --> I
I --> J{subflowInserts.length > 0?}
J -- Yes --> K[Chunk subflowInserts into groups of 50]
K --> L[INSERT each chunk into workflowSubflows]
J -- No --> M[Done]
L --> M
style D fill:#d4edda,stroke:#28a745
style G fill:#d4edda,stroke:#28a745
style K fill:#d4edda,stroke:#28a745
Reviews (1): Last reviewed commit: "Merge staging into fix/workflow-persiste..." | Re-trigger Greptile |
| // Map edge IDs | ||
|
|
||
| ;(state.edges || []).forEach((edge: Edge) => { | ||
| edgeIdMapping.set(edge.id, crypto.randomUUID()) | ||
| }) | ||
| ; (state.edges || []).forEach((edge: Edge) => { | ||
| edgeIdMapping.set(edge.id, crypto.randomUUID()) | ||
| }) |
There was a problem hiding this comment.
Inconsistent indentation introduced
The "Map edge IDs" block (comment + forEach) has been re-indented to 4 spaces, while every other statement at the same scope level uses 2-space indentation (see lines 817–820, 828–836). This makes the block visually appear nested inside the previous forEach, which it is not.
| // Map edge IDs | |
| ;(state.edges || []).forEach((edge: Edge) => { | |
| edgeIdMapping.set(edge.id, crypto.randomUUID()) | |
| }) | |
| ; (state.edges || []).forEach((edge: Edge) => { | |
| edgeIdMapping.set(edge.id, crypto.randomUUID()) | |
| }) | |
| // Map edge IDs | |
| ;(state.edges || []).forEach((edge: Edge) => { | |
| edgeIdMapping.set(edge.id, crypto.randomUUID()) | |
| }) |
| }) | ||
|
|
||
| // Regenerate edges with updated source/target references | ||
| // Regenerate edges with updated source/target references |
There was a problem hiding this comment.
Comment indented to wrong level
This comment was shifted to 4-space indentation, but the forEach call it labels on line 902 remains at 2-space indentation. The mismatch makes the comment appear detached from the code it describes.
| // Regenerate edges with updated source/target references | |
| // Regenerate edges with updated source/target references |
Fixes #2424
Type of Change
Testing
This has been tested by manually resolving the merge conflicts with the latest
stagingbranch and ensuring the persistence logic correctly chunks database insertions.CHUNK_SIZE = 50logic insaveWorkflowToNormalizedTablesand the correct sequencing of loop/parallel subflow inserts. This ensures compatibility with SQLite's 999-parameter limit while incorporating recent staging improvements for edge remapping.Checklist