fix(serializer): preserve block enabled state during deserialization#3950
fix(serializer): preserve block enabled state during deserialization#3950lawrence3699 wants to merge 3 commits intosimstudioai:stagingfrom
Conversation
…ership workflow edits via sockets, ui improvements
The deserializer hardcodes `enabled: true` for regular blocks, ignoring the `enabled` field that was correctly saved during serialization. This causes disabled blocks to silently become re-enabled when a workflow is loaded, imported, or round-tripped through serialize/deserialize. The loop/parallel branch already handles this correctly with `serializedBlock.enabled ?? true` — apply the same pattern to regular blocks.
PR SummaryLow Risk Overview Regular blocks now use Reviewed by Cursor Bugbot for commit 5035869. 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. |
There was a problem hiding this comment.
Pull request overview
Fixes workflow deserialization to preserve a block’s saved enabled state instead of re-enabling regular blocks unconditionally, preventing disabled blocks from silently becoming enabled after reload/import/round-trip.
Changes:
- Update regular block deserialization to use
serializedBlock.enabled ?? true, matching the existing loop/parallel behavior. - Maintain backward-compatible defaulting to
truewhenenabledis absent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| position: serializedBlock.position, | ||
| subBlocks, | ||
| outputs: serializedBlock.outputs, | ||
| enabled: true, | ||
| enabled: serializedBlock.enabled ?? true, | ||
| triggerMode: |
There was a problem hiding this comment.
This change will require updating the existing unit test that currently asserts the buggy behavior. apps/sim/serializer/tests/serializer.extended.test.ts has a case (should deserialize enabled status correctly) where enabled: false is expected to deserialize to true; after preserving enabled, it should assert false (and ideally add a separate assertion for the backward-compat default when enabled is missing).
| outputs: serializedBlock.outputs, | ||
| enabled: true, | ||
| enabled: serializedBlock.enabled ?? true, | ||
| triggerMode: |
There was a problem hiding this comment.
SerializedBlock.enabled is currently typed as a required boolean (apps/sim/serializer/types.ts), but deserialization now treats it as optional via serializedBlock.enabled ?? true for backward compatibility. Consider updating the SerializedBlock type (or introducing a versioned/migrated type) so the TypeScript types match the actual data shape coming from persisted workflows.
Greptile SummaryThis PR fixes a silent state-loss bug in the workflow deserializer where regular blocks always came back as
Confidence Score: 5/5Safe to merge — the one-line fix is unambiguously correct and carries no regression risk. The change mirrors the exact pattern already in use for loop/parallel blocks at line 594, the serialization side (line 294) already persists the field, and the No files require special attention; the single changed line in Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Workflow UI
participant S as Serializer
Note over UI,S: Save / Export
UI->>S: serializeWorkflow(blocks)
S-->>UI: SerializedBlock { enabled: false }
Note over UI,S: Load / Import — Before Fix
UI->>S: deserializeWorkflow(serialized)
S-->>UI: BlockState { enabled: true } ❌ hardcoded
Note over UI,S: Load / Import — After Fix
UI->>S: deserializeWorkflow(serialized)
S->>S: serializedBlock.enabled ?? true
S-->>UI: BlockState { enabled: false } ✅ preserved
|
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 29606901 | Triggered | Generic High Entropy Secret | a54dcbe | apps/sim/providers/utils.test.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Summary
The deserializer hardcodes
enabled: truefor regular blocks (line 625), ignoring theenabledfield that was correctly saved during serialization (line 294). This causes disabled blocks to silently become re-enabled when a workflow is loaded, imported, or round-tripped through serialize/deserialize.The loop/parallel branch at line 594 already handles this correctly with
serializedBlock.enabled ?? true. This PR applies the same pattern to regular blocks.Reproduction
Fix
Change
enabled: true→enabled: serializedBlock.enabled ?? trueto match the pattern already used for loop/parallel blocks.Test plan
enabledfield in serialized blocks default totrue(backwards compatible)