Skip to content

fix(manual): mock payloads nested recursion#4037

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/mock-payload
Apr 8, 2026
Merged

fix(manual): mock payloads nested recursion#4037
icecrasher321 merged 1 commit intostagingfrom
fix/mock-payload

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Manual execs had incorrect mock payloads for nested structures.

Type of Change

  • Bug fix

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
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 8, 2026 3:43am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 8, 2026

PR Summary

Medium Risk
Changes mock payload generation for trigger outputs by expanding schema-defined nested objects/arrays, which could alter the shape of sample payloads used in manual/external trigger runs. Risk is moderate due to recursive processing and potential edge cases in diverse output schemas.

Overview
Fixes mock payload generation to correctly recurse into JSON-Schema-style output definitions. processOutputField now expands nested object/json fields via properties and array fields via items, instead of returning generic placeholder objects/arrays for these typed nodes.

This results in generated mock payloads that better match deeply nested trigger output schemas during manual/external trigger execution.

Reviewed by Cursor Bugbot for commit 4f8b70b. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR fixes incorrect mock payload generation for nested structures during manual workflow execution. The processOutputField function in trigger-utils.ts previously fell through to generateMockValue for every typed field, returning generic placeholders ({ id: 'sample_id', ... }) even when the field schema had properties (for objects/JSON) or items (for arrays) that could be expanded into richer, schema-accurate mock data.

Key changes:

  • Object/JSON fields with properties: The function now recursively expands the nested schema into a concrete mock object instead of returning the generic { id: 'sample_id', name: 'Sample Object', status: 'active' } fallback.
  • Array fields with items: The function now calls processOutputField on the items schema and wraps the result in a single-element array, matching the shape downstream workflows expect.
  • The maxDepth guard (default 10) ensures there is no infinite recursion risk for deeply or circularly nested schemas.
  • The JSDoc comment on processOutputField is updated to accurately reflect the expanded behavior.

Confidence Score: 5/5

Safe to merge — the fix is a targeted, well-guarded extension of the existing recursive mock-generation logic with no regressions to existing branches.

All remaining findings from prior review rounds are P2 or already resolved (the tuple-items guard concern was dismissed by the senior dev; the test-coverage gap was already flagged). The new code is logically correct, bounded by maxDepth, and follows project conventions. No P0/P1 issues are present.

No files require special attention.

Vulnerabilities

No security concerns identified. The change is confined to mock payload generation with a bounded recursion depth guard (maxDepth = 10), and the generated data is never persisted or returned to external callers.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/triggers/trigger-utils.ts Adds two new recursive branches to processOutputField to correctly expand JSON-Schema-style properties (objects/JSON) and items (arrays) into realistic mock values; logic is sound and protected by the existing maxDepth guard.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[processOutputField key, field, depth] --> B{depth > maxDepth?}
    B -- yes --> C[return null]
    B -- no --> D{field has 'type' string?}
    D -- no --> E{field is plain object?}
    E -- yes --> F[Recurse into each key]
    E -- no --> G[return null]
    D -- yes --> H{type is 'object'/'json' AND has properties?}
    H -- yes --> I[NEW: Iterate properties, recurse each nestedField]
    I --> J[return nestedObject Record]
    H -- no --> K{type is 'array' AND has items object?}
    K -- yes --> L[NEW: Recurse on items schema]
    L --> M[return itemValue array]
    K -- no --> N[generateMockValue type, description, key]
    N --> O[return primitive/generic mock]
Loading

Reviews (2): Last reviewed commit: "fix(manual): mock payloads nested recurs..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@cursor review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Tip:

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

@icecrasher321 icecrasher321 merged commit a591d7c into staging Apr 8, 2026
12 checks passed
Copy link
Copy Markdown

@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

Reviewed by Cursor Bugbot for commit 4f8b70b. Configure here.

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