fix(sanitize): repair malformed subblock states#4490
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Updates Adjusts the migration pipeline ordering so subBlock repairs run before credential ID migration, hardens credential migration against non-object subBlocks, and adds optimistic persistence for migrated blocks by tracking per-block Reviewed by Cursor Bugbot for commit b2c6df2. Configure here. |
Greptile SummaryThis PR replaces the previous approach of silently dropping malformed subblock entries with a repair-first strategy: a new
Confidence Score: 5/5Safe to merge — the repair path is well-guarded and the write-back uses optimistic concurrency, so a concurrent user save is never overwritten. The changes are narrowly scoped to migration and sanitization utilities. The sanitizer's guard ordering is correct, the credential migration gains a defensive null-check, and the optimistic-concurrency lock on write-back prevents data loss. The only finding is a redundant second sanitization pass in the import path, which is a minor efficiency concern with no correctness impact. No files require special attention; the double-sanitization pass in normalizeSubblockValues inside import-export.ts is the only point worth a follow-up. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Load workflow blocks from DB] --> B[applyBlockMigrations pipeline]
B --> C[migrateAgentBlocksToMessagesFormat]
C --> D[migrateSubblockIds]
D --> D1{renames for block type?}
D1 -- yes --> D2[migrateBlockSubblockIds\nrenames IDs, fixes unknown types]
D1 -- no --> D3[passthrough]
D2 --> D4[sanitizeMalformedSubBlocks\nrepair or drop bad entries]
D3 --> D4
D4 --> E[migrateCredentialIds\nnow guards non-object subBlocks]
E --> F[backfillCanonicalModes]
F --> G{any migrated?}
G -- yes --> H[persistMigratedBlocks\nwith OCC updatedAt guard]
G -- no --> I[return blocks to caller]
H --> I
J[parseWorkflowJson import] --> K[unwrapWorkflowExportEnvelope\nstrips data envelope if present]
K --> L[normalizeSubblockValues]
L --> L1[migrateSubblockIds\nincludes sanitizeMalformedSubBlocks]
L1 --> L2[sanitizeMalformedSubBlocks again\nwith convertEmptyStringToNull]
L2 --> M[Zod validation]
Reviews (2): Last reviewed commit: "address comment" | Re-trigger Greptile |
|
bugbot run |
|
@greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b2c6df2. Configure here.
Summary
Repair malformed subblock states from older workflows rather than preventing loading.
Type of Change
Testing
Tested manually
Checklist