Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Jan 3, 2026

Summary

Fixes variables block parsing error for json strings

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 3, 2026 10:37pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 3, 2026

Greptile Summary

Added parseVariableAssignments helper function to handle cases where variable assignments are stringified JSON during workflow import, preventing parsing errors when workflows contain JSON-serialized variable data.

  • Created defensive parser that handles both array and stringified JSON array inputs
  • Validates JSON array format before parsing (checks for brackets)
  • Gracefully falls back to empty array on parse errors
  • Applied parser to both preview and store values before usage

Confidence Score: 4/5

  • Safe to merge with minimal risk
  • The implementation adds defensive parsing for JSON strings with proper error handling and fallback behavior. The logic is straightforward and handles edge cases well (empty values, already-parsed arrays, malformed JSON). No breaking changes to existing functionality.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/variables-input/variables-input.tsx Added parseVariableAssignments helper to handle JSON string parsing for imported workflows with stringified variable assignments

Sequence Diagram

sequenceDiagram
    participant Component as VariablesInput
    participant Parser as parseVariableAssignments
    participant Store as useSubBlockValue
    
    Component->>Store: Get storeValue or previewValue
    Store-->>Component: Return raw value (array or string)
    
    Component->>Parser: parseVariableAssignments(rawValue)
    
    alt value is falsy
        Parser-->>Component: Return []
    else value is Array
        Parser-->>Component: Return value as VariableAssignment[]
    else value is string with JSON array
        Parser->>Parser: JSON.parse(trimmed)
        alt parse success and is array
            Parser-->>Component: Return parsed array
        else parse error
            Parser-->>Component: Return []
        end
    else other type
        Parser-->>Component: Return []
    end
    
    Component->>Component: Use assignments for rendering
Loading

@Sg312 Sg312 merged commit 1673ef9 into staging Jan 3, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/variables-block-parsing branch January 4, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants