Skip to content

fix(resolver): turn off resolver for opaque schema nodes, unrun paths#4208

Merged
icecrasher321 merged 3 commits intostagingfrom
fix/resolver-path
Apr 17, 2026
Merged

fix(resolver): turn off resolver for opaque schema nodes, unrun paths#4208
icecrasher321 merged 3 commits intostagingfrom
fix/resolver-path

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Turn off InvalidFieldErrors for:

  • Opaque schema outputs: e.g. function can return conditional json
  • Path is not executed

Type of Change

  • Bug fix

Testing

Tested manually and added tests.

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 17, 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 17, 2026 1:32am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 17, 2026

PR Summary

Medium Risk
Touches core resolver behavior for schema validation and loop/parallel item resolution, which can change when workflows fail vs. silently treat values as empty on branched paths.

Overview
Prevents InvalidFieldError for references that point to blocks that did not execute (branched/untaken paths) by returning undefined without schema-path validation, allowing callers to treat them as empty values.

Schema-path validation now treats type: 'json' / type: 'object' nodes without declared properties (and type: 'any') as opaque, permitting arbitrary nested paths under those fields without throwing when runtime data is missing.

resolveArrayInput now treats pure references that resolve to null (skipped block) as an empty collection ([]), so loops/parallels run zero iterations instead of failing; tests were added/updated to cover these cases.

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 17, 2026

Greptile Summary

This PR fixes two related bugs where the block reference resolver threw InvalidFieldError in cases where it shouldn't: (1) when a block lives on a branched path that wasn't taken in the current run, and (2) when a reference drills into a json/object/any schema field whose inner shape is intentionally undeclared (opaque). It also handles the downstream effect in resolveArrayInput, returning an empty array when a loop or parallel block references a skipped block rather than throwing.

Confidence Score: 5/5

Safe to merge — all findings are P2 style issues in the new test file only.

The production logic changes are well-reasoned, correctly implemented, and backed by targeted unit and integration tests. The three comments are minor test-file style issues (missing environment directive, relative import, as any cast) that don't affect correctness or runtime behaviour.

apps/sim/executor/utils/subflow-utils.test.ts — relative import, missing @vitest-environment node, and as any cast.

Important Files Changed

Filename Overview
apps/sim/executor/utils/block-reference.ts Adds isOpaqueSchemaNode to bypass path validation for json/object/any schema nodes without declared properties; removes path validation entirely when a block has no output (skipped/branched path). Logic is correct and well-targeted.
apps/sim/executor/utils/subflow-utils.ts Adds null guard in resolveArrayInput so a loop/parallel over a skipped-block reference runs zero iterations instead of throwing. Placed correctly between the object check (which excludes null) and the error throw.
apps/sim/executor/utils/subflow-utils.test.ts New test file covering all branches of resolveArrayInput. Missing @vitest-environment node, uses a relative import and as any cast — all P2.
apps/sim/executor/utils/block-reference.test.ts Updates existing test to match new behaviour (no throw on unrun path) and adds three new cases covering opaque json schema nodes — well-documented and thorough.
apps/sim/executor/variables/resolvers/block.test.ts Adds two integration-level tests reproducing the branched-trigger CRM workflow bug — one for unexecuted blocks and one for executed blocks with a missing dynamic key.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[resolveBlockReference called] --> B{blockId found?}
    B -- No --> C[return undefined]
    B -- Yes --> D{blockOutput === undefined?}
    D -- Yes\n(block not executed / branched path) --> E[return value: undefined\nno schema validation]
    D -- No --> F{pathParts empty?}
    F -- Yes --> G[return full blockOutput]
    F -- No --> H[navigatePath through blockOutput]
    H --> I{value === undefined?}
    I -- No --> J[return value]
    I -- Yes --> K{schema exists?}
    K -- No --> J
    K -- Yes --> L[isPathInSchema check]
    L --> M{path valid?}
    M -- Yes --> J
    M -- No --> N[throw InvalidFieldError]

    subgraph isPathInSchema
        O[walk schema nodes] --> P{isOpaqueSchemaNode?\ntype: json/object/any\nwithout properties}
        P -- Yes --> Q[return true\nany sub-path accepted]
        P -- No --> R[lookupField / array traversal]
        R --> S{field found?}
        S -- No --> T[return false]
        S -- Yes --> O
    end
Loading

Reviews (1): Last reviewed commit: "fix subflows to make them consistent" | Re-trigger Greptile

Comment thread apps/sim/executor/utils/subflow-utils.test.ts
Comment thread apps/sim/executor/utils/subflow-utils.test.ts
Comment thread apps/sim/executor/utils/subflow-utils.test.ts Outdated
@icecrasher321 icecrasher321 merged commit 3d909d5 into staging Apr 17, 2026
9 checks passed
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.

1 participant