Skip to content

fix(executor): prevent raw workflowInput from overwriting coerced start block values#3347

Open
waleedlatif1 wants to merge 1 commit intostagingfrom
waleedlatif1/preserve-typed-workflow-inputs
Open

fix(executor): prevent raw workflowInput from overwriting coerced start block values#3347
waleedlatif1 wants to merge 1 commit intostagingfrom
waleedlatif1/preserve-typed-workflow-inputs

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Feb 26, 2026

Summary

  • Prevent buildUnifiedStartOutput and buildIntegrationTriggerOutput from overwriting schema-coerced structuredInput values with raw workflowInput strings
  • Add structuredKeys guard so the workflowInput loop skips keys already set by coerceValue, preserving typed values (arrays, objects, numbers, booleans) passed to child workflows

Type of Change

  • Bug fix

Testing

  • bun run --filter sim test -- executor/utils/start-block.test.ts (11 tests pass)
  • New tests: coerced type preservation (number, object, boolean), structured key priority over duplicated workflowInput keys, EXTERNAL_TRIGGER path

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)

Fixes #3105

@vercel
Copy link

vercel bot commented Feb 26, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 26, 2026 3:51am

Request Review

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/preserve-typed-workflow-inputs branch from 11d8350 to 28d1545 Compare February 26, 2026 03:08
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR fixes a bug where raw workflowInput string values would overwrite schema-coerced typed values (numbers, objects, booleans) set by coerceValue in the start block output builders.

  • Adds a structuredKeys guard in both buildUnifiedStartOutput and buildIntegrationTriggerOutput that skips workflowInput keys already present in structuredInput, preserving typed values produced by coerceValue
  • Keys not in the schema are still passed through from workflowInput, maintaining backward compatibility
  • Adds 3 well-structured test cases covering type preservation for the UNIFIED and EXTERNAL_TRIGGER paths, including a priority test with duplicated keys

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, well-tested bug fix with no risk of regressions.
  • The change is small (6 lines of logic added), surgically targeted, and preserves backward compatibility for keys not in the input schema. The fix is applied consistently to both affected functions. Three new tests directly validate the fix, and the overall test suite passes.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/executor/utils/start-block.ts Adds structuredKeys guard in buildUnifiedStartOutput and buildIntegrationTriggerOutput to prevent raw workflowInput strings from overwriting schema-coerced typed values. Clean, minimal fix.
apps/sim/executor/utils/start-block.test.ts Adds 3 new test cases covering coerced type preservation (number, object, boolean) for both UNIFIED and EXTERNAL_TRIGGER paths, including priority over duplicated workflowInput keys.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[buildStartBlockOutput] --> B[deriveInputFromFormat]
    B --> C{hasStructured?}
    C -->|Yes| D[coerceValue per field → structuredInput]
    C -->|No| E[Pass raw workflowInput through]
    D --> F[buildUnifiedStartOutput / buildIntegrationTriggerOutput]
    F --> G[Copy structuredInput to output]
    G --> H{workflowInput key in structuredKeys?}
    H -->|Yes - NEW GUARD| I[Skip — preserve coerced value]
    H -->|No| J[Merge workflowInput value into output]
    I --> K[Return output]
    J --> K
Loading

Last reviewed commit: b3687a8

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.

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Additional Comments (1)

apps/sim/executor/utils/start-block.ts
Same overwrite issue exists here

buildIntegrationTriggerOutput has the same pattern that was fixed in buildUnifiedStartOutput — it writes schema-coerced structuredInput keys first (line 393-394), then iterates workflowInput and unconditionally overwrites them (line 400-401) when the raw value is non-null. Consider applying the same structuredKeys guard here for consistency:

  if (isPlainObject(workflowInput)) {
    const structuredKeys = hasStructured ? new Set(Object.keys(structuredInput)) : null
    for (const [key, value] of Object.entries(workflowInput)) {
      if (structuredKeys?.has(key)) continue
      if (value !== undefined && value !== null) {
        output[key] = value
      } else if (!Object.hasOwn(output, key)) {
        output[key] = value
      }
    }
  }

@waleedlatif1 waleedlatif1 changed the title fix: preserve typed values when resolving workflow inputMapping references fix(types): preserve typed values when resolving workflow inputMapping references Feb 26, 2026
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/preserve-typed-workflow-inputs branch from 28d1545 to 9e6c6ec Compare February 26, 2026 03:12
@waleedlatif1 waleedlatif1 changed the base branch from main to staging February 26, 2026 03:12
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/preserve-typed-workflow-inputs branch from 9e6c6ec to c1e64ff Compare February 26, 2026 03:13
@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

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

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/preserve-typed-workflow-inputs branch from c1e64ff to 539ad3d Compare February 26, 2026 03:48
@waleedlatif1 waleedlatif1 changed the title fix(types): preserve typed values when resolving workflow inputMapping references fix: prevent raw workflowInput from overwriting coerced start block values Feb 26, 2026
@waleedlatif1 waleedlatif1 changed the title fix: prevent raw workflowInput from overwriting coerced start block values fix(executor): prevent raw workflowInput from overwriting coerced start block values Feb 26, 2026
…alues

buildUnifiedStartOutput and buildIntegrationTriggerOutput first populate
output with schema-coerced structuredInput values (via coerceValue), then
iterate workflowInput and unconditionally overwrite those keys with raw
strings. This causes typed values (arrays, objects, numbers, booleans)
passed to child workflows to arrive as stringified versions.

Add a structuredKeys guard so the workflowInput loop skips keys already
set by the coerced structuredInput, letting coerceValue's type-aware
parsing (JSON.parse for objects/arrays, Number() for numbers, etc.)
take effect.

Fixes #3105

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/preserve-typed-workflow-inputs branch from 539ad3d to b3687a8 Compare February 26, 2026 03:51
@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link

@cursor cursor bot left a comment

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

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.

Data type information lost when workflow_input passes data to child workflow start_trigger

1 participant