Skip to content

Step-level if conditions crash when referencing skipped step output #89

@ameet

Description

@ameet

Description

When a flow step has an `if` condition and is skipped at runtime, downstream steps that reference `$.steps.X.output.Y` in their own `if` conditions crash with:

Cannot read properties of undefined (reading 'Y')

The `(x || {}).y` null-guard pattern works inside `code` step JavaScript, but does NOT work in step-level `if` conditions for `file-write`, `bash`, or `flow` steps.

Reproduction

{
  "id": "stepA",
  "type": "code",
  "if": "$.input.someFlag === true",
  "code": { "source": "return { result: 'hello' };" }
},
{
  "id": "stepB",
  "type": "file-write",
  "if": "$.steps.stepA.output.result",
  "fileWrite": { "path": "/tmp/test.txt", "content": "test" }
}

When `someFlag` is false, stepA is skipped. stepB's `if` condition evaluates `$.steps.stepA.output.result` — but `$.steps.stepA` is undefined, causing a crash.

Workaround

Remove the `if` condition from the parse step so it always runs, producing a default output:

{
  "id": "stepA",
  "type": "code",
  "code": { "source": "var upstream = ($.steps.someStep || {}).output; if (!upstream) return { skip: true }; return { result: upstream };" }
}

Suggested Fix

Add null-safe property access in `if` condition evaluation. If any segment of the dot-path resolves to `undefined`, the condition should evaluate to `false` (not crash).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions