Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Nov 20, 2025

Summary

  1. Array/JSON fields marked incorrectly for attachments
  2. Parsing was stringifying them instead passing them through

Type of Change

  • Bug fix

Testing

Tested manually by downloading attachments via Gmail trigger and passing it to Gmail block to send.

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 Nov 20, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 20, 2025 8:22am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 20, 2025

Greptile Overview

Greptile Summary

Fixed inconsistent handling of array/JSON fields in block configurations by centralizing parsing logic and correcting field type definitions.

Key Changes:

  • Centralized JSON/array parsing in generic-handler.ts to handle stringified values from variable resolution
  • Changed attachment/file fields from type: 'json' to type: 'array' for accurate type representation (Discord, Gmail, Slack, Telegram, Teams, Outlook, SharePoint)
  • Removed redundant manual JSON parsing from block-specific code (Firecrawl, HubSpot, Mem0, Zep)
  • Simplified validation logic in Mem0 and Zep blocks

Benefits:

  • DRY principle: parsing logic now exists in one place instead of duplicated across multiple blocks
  • Type accuracy: array fields correctly marked as array instead of generic json
  • Consistent error handling: failed parsing now logs warnings instead of throwing errors inconsistently

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes follow a clear refactoring pattern: centralizing parsing logic in the generic handler and fixing type definitions. The logic is sound - it only attempts JSON parsing on string values for fields marked as json or array types, with proper error handling. All manual parsing code was correctly removed from blocks that now rely on the centralized handler. The changes improve code quality, reduce duplication, and maintain backward compatibility.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/executor/handlers/generic/generic-handler.ts 5/5 Added centralized JSON/array parsing logic to handle stringified values from variable resolution
apps/sim/blocks/blocks/firecrawl.ts 5/5 Removed manual JSON parsing for formats and urls fields, now handled by generic handler
apps/sim/blocks/blocks/hubspot.ts 5/5 Removed manual JSON parsing for json fields (propertiesToSet, searchProperties, filterGroups, sorts), now handled by generic handler
apps/sim/blocks/blocks/mem0.ts 5/5 Simplified messages validation by removing JSON parsing logic, now handled by generic handler
apps/sim/blocks/blocks/zep.ts 5/5 Simplified messages validation and assignment by removing JSON parsing logic, now handled by generic handler

Sequence Diagram

sequenceDiagram
    participant Client as Workflow Executor
    participant GH as GenericBlockHandler
    participant BC as BlockConfig
    participant Tool as Tool Executor

    Client->>GH: execute(block, inputs)
    
    Note over GH: Extract blockConfig from block.metadata
    
    GH->>BC: getBlock(blockType)
    BC-->>GH: blockConfig with inputs schema
    
    alt blockConfig has params transformer
        GH->>BC: blockConfig.tools.config.params(inputs)
        BC-->>GH: transformedParams
        Note over GH: Merge transformed params into finalInputs
    end
    
    Note over GH: JSON/Array Parsing Phase
    loop For each input field in blockConfig.inputs
        alt field type is 'json' OR 'array'
            alt value is string
                GH->>GH: JSON.parse(value.trim())
                Note over GH: Parse stringified arrays/objects<br/>from variable resolution
            end
        end
    end
    
    GH->>Tool: executeTool(toolName, finalInputs, context)
    Tool-->>GH: result
    
    alt Success
        GH-->>Client: output data
    else Failure
        GH-->>Client: throw error with details
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit 472aff5 into staging Nov 20, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/resolver-types-array-json branch November 20, 2025 19:19
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