Skip to content

improvement(block-inputs): must parse json accurately + models max_tokens fix - #3033

Merged
icecrasher321 merged 7 commits into
stagingfrom
improvement/json-inputs-blocks
Jan 28, 2026
Merged

improvement(block-inputs): must parse json accurately + models max_tokens fix#3033
icecrasher321 merged 7 commits into
stagingfrom
improvement/json-inputs-blocks

Conversation

@icecrasher321

@icecrasher321icecrasher321 commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Models fix to check max_tokens correctly
  • Parse json for block logs

Type of Change

  • Other: UX Improvement

Testing

Tested manually

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

vercelBot commented Jan 28, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentReviewUpdated (UTC)
docsSkippedSkippedJan 28, 2026 1:57am

Request Review

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR improves type safety and log display by correctly handling JSON inputs across 24 block integrations and the block executor.

Key Changes:

  • Changed input type declarations from 'string' to 'json' for parameters that accept JSON objects/arrays across all block integrations (Apollo, Elasticsearch, GitHub, MongoDB, PostHog, Mailchimp, etc.)
  • Added new parseJsonInputs() method in block-executor.ts that parses JSON strings for log display
  • Applied JSON parsing to block logs at three key points: initial input logging, success callback, and error callback
  • The parsing is defensive: only attempts to parse strings that look like JSON (start with { or [), wrapped in try-catch to gracefully handle invalid JSON

Impact:

  • Block logs will now display parsed JSON objects/arrays instead of raw JSON strings, improving readability
  • Type declarations now accurately reflect that these inputs expect JSON structures
  • No changes to actual block execution logic - parsing is purely for display purposes

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - changes are primarily type annotations and defensive log formatting
  • Score of 4 reflects that the changes are well-contained and defensive (try-catch protection), but the isJSONString heuristic could be improved to avoid unnecessary parse attempts on non-JSON strings
  • No files require special attention - all changes follow the same safe pattern

Important Files Changed

FilenameOverview
apps/sim/executor/execution/block-executor.tsAdded parseJsonInputs method to parse JSON strings for log display; method uses isJSONString check and safely handles parse errors
apps/sim/blocks/blocks/apollo.tsAdded 14 new input fields with type 'json' for arrays and objects used in Apollo operations
apps/sim/blocks/blocks/elasticsearch.tsChanged 6 input types from 'string' to 'json' for document, query, sort, operations, settings, and mappings
apps/sim/blocks/blocks/mongodb.tsChanged 5 input types from 'string' to 'json' for query, sort, filter, update, and pipeline parameters
apps/sim/blocks/blocks/posthog.tsChanged 10 input types from 'string' to 'json' and added 5 new json-type inputs for properties, filters, and configurations
apps/sim/blocks/blocks/mailchimp.tsAdded 9 new json-type inputs for contact, campaign settings, recipients, merge fields, and batch operations

Sequence Diagram

sequenceDiagram
participant User
participant BlockExecutor
participant VariableResolver
participant parseJsonInputs
participant BlockLog
participant onBlockComplete
User->>BlockExecutor: Execute block with inputs
BlockExecutor->>VariableResolver: resolveInputs(ctx, params)
VariableResolver-->>BlockExecutor: resolvedInputs (strings)
alt Block logging enabled
BlockExecutor->>parseJsonInputs: parseJsonInputs(resolvedInputs)
parseJsonInputs->>parseJsonInputs: Check each value with isJSONString()
parseJsonInputs->>parseJsonInputs: JSON.parse() on JSON-like strings
parseJsonInputs-->>BlockExecutor: parsed inputs (objects/arrays)
BlockExecutor->>BlockLog: Set blockLog.input with parsed data
end
BlockExecutor->>BlockExecutor: Execute block operation
alt Success path
BlockExecutor->>parseJsonInputs: parseJsonInputs(resolvedInputs)
parseJsonInputs-->>BlockExecutor: parsed inputs
BlockExecutor->>onBlockComplete: callback(ctx, node, block, parsed inputs, output)
else Error path
BlockExecutor->>parseJsonInputs: parseJsonInputs(input)
parseJsonInputs-->>BlockExecutor: parsed inputs
BlockExecutor->>BlockLog: Set blockLog.input with parsed data
BlockExecutor->>onBlockComplete: callback(ctx, node, block, parsed inputs, errorOutput)
end
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment threadapps/sim/executor/execution/block-executor.ts
Comment threadapps/sim/blocks/blocks/google_sheets.ts Outdated
@icecrasher321

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@icecrasher321

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@icecrasher321icecrasher321 changed the title improvement(block-inputs): must parse json accuratelyimprovement(block-inputs): must parse json accurately + models max_tokens fixJan 28, 2026
Comment threadapps/sim/blocks/blocks/elasticsearch.ts Outdated

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment threadapps/sim/providers/groq/index.ts
@icecrasher321
icecrasher321 merged commit 65bc216 into stagingJan 28, 2026
12 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/json-inputs-blocks branch January 28, 2026 02:30
royceP2 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Mar 3, 2026
…kens fix (simstudioai#3033)
* improvement(block-inputs): must parse json accurately
* fix sheets typing
* add reference comment
* fix models
* revert blocks changes
* fix param to follow openai new convention
Sign up for freeto 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.

1 participant

@icecrasher321