fix(import): fix missing blocks in import if undefined keys exist#2674
fix(import): fix missing blocks in import if undefined keys exist#2674
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes a bug where workflow imports would fail due to malformed subBlocks with key Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Export as Export/Sanitize
participant CE as credential-extractor.ts
participant Import as importer.ts
participant Store as Workflow Store
Note over User,Store: Export Flow
User->>Export: Export workflow
Export->>CE: sanitizeWorkflowForSharing()
CE->>CE: removeMalformedSubBlocks()
Note over CE: Filter out:<br/>- key === "undefined"<br/>- !subBlock or typeof !== object<br/>- type === "unknown"<br/>- !subBlock.id
CE->>CE: Delete malformed subBlocks
CE-->>Export: Clean workflow state
Export-->>User: JSON file
Note over User,Store: Import Flow
User->>Import: Import workflow JSON
Import->>Import: parseWorkflowJson()
Import->>Import: normalizeSubblockValues()
Note over Import: Skip (with logging):<br/>- subBlockId === "undefined"<br/>- !subBlock or typeof !== object<br/>- type === "unknown"<br/>- !subBlock.id
Import->>Import: Build normalizedSubBlocks
Import-->>Store: Clean workflow state
|
| if (!subBlock || typeof subBlock !== 'object') { | ||
| logger.warn(`Skipping invalid subBlock ${subBlockId} in block ${blockId}: not an object`) | ||
| return | ||
| } |
There was a problem hiding this comment.
style: In JavaScript, arrays pass the typeof !== 'object' check since typeof [] === 'object'. Consider adding !Array.isArray(subBlock) to explicitly reject arrays
| if (!subBlock || typeof subBlock !== 'object') { | |
| logger.warn(`Skipping invalid subBlock ${subBlockId} in block ${blockId}: not an object`) | |
| return | |
| } | |
| // Skip subBlocks that are null or not objects | |
| if (!subBlock || typeof subBlock !== 'object' || Array.isArray(subBlock)) { | |
| logger.warn(`Skipping invalid subBlock ${subBlockId} in block ${blockId}: not an object`) | |
| return | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/stores/workflows/json/importer.ts
Line: 34:37
Comment:
**style:** In JavaScript, arrays pass the `typeof !== 'object'` check since `typeof [] === 'object'`. Consider adding `!Array.isArray(subBlock)` to explicitly reject arrays
```suggestion
// Skip subBlocks that are null or not objects
if (!subBlock || typeof subBlock !== 'object' || Array.isArray(subBlock)) {
logger.warn(`Skipping invalid subBlock ${subBlockId} in block ${blockId}: not an object`)
return
}
```
How can I resolve this? If you propose a fix, please make it concise.| if (!subBlock || typeof subBlock !== 'object') { | ||
| keysToRemove.push(key) | ||
| return | ||
| } |
There was a problem hiding this comment.
style: Arrays pass the typeof !== 'object' check since typeof [] === 'object'. Consider adding !Array.isArray(subBlock) to explicitly reject arrays
| if (!subBlock || typeof subBlock !== 'object') { | |
| keysToRemove.push(key) | |
| return | |
| } | |
| // Flag subBlocks that are null or not objects | |
| if (!subBlock || typeof subBlock !== 'object' || Array.isArray(subBlock)) { | |
| keysToRemove.push(key) | |
| return | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/workflows/credentials/credential-extractor.ts
Line: 184:187
Comment:
**style:** Arrays pass the `typeof !== 'object'` check since `typeof [] === 'object'`. Consider adding `!Array.isArray(subBlock)` to explicitly reject arrays
```suggestion
// Flag subBlocks that are null or not objects
if (!subBlock || typeof subBlock !== 'object' || Array.isArray(subBlock)) {
keysToRemove.push(key)
return
}
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Fix missing blocks in import if undefined keys exist
Type of Change
Testing
Manual
Checklist