Skip to content

[Engine] Code steps don't support optional chaining (?.) — no clear error #42

@ameet

Description

@ameet

Component

Flow engine — code step runtime

What's wrong?

Code steps silently fail or throw cryptic errors when using JavaScript optional chaining (?.), which has been standard since ES2020 (Node 14+, 2020).

Description

Any code step using foo?.bar or arr?.[0] either:

  • Fails silently (returns undefined where it shouldn't)
  • Throws an unhelpful syntax error with no mention of optional chaining

The correct pattern is (foo || {}).bar or (arr || [])[0], but every AI coding agent (Claude, GPT, Copilot) generates ?. by default since it's been standard JS for 6 years.

Scale of impact: We had to purge ?. from 69 flows in a single session and now maintain a regression test (brittleness_regression.py) that scans all code steps for ?. usage to prevent reintroduction.

How we discovered this

Flows that worked in local Node testing broke when executed via one flow execute. Root cause was ?. in code steps. Commit 44129c2 documents the mass fix across multiple flows.

Examples

Fails:

const data = $.steps.enrichment?.output?.company;

Works (our workaround):

const data = (($.steps.enrichment || {}).output || {}).company;

Suggested fix

Either:

  1. Support optional chaining — upgrade the code step runtime to a modern JS engine/parser
  2. Clear error message — if ?. is detected, throw: "Optional chaining (?.) is not supported in code steps. Use (x || {}).y instead."
  3. Lint at load timeone flow validate could flag ?. before execution

Option 1 is ideal. Option 2 would save hours of debugging. We currently handle this with option 3 via a custom script.

Source

  • MDN: Optional chaining — standard since ES2020
  • Our workaround: brittleness_regression.py scans 372 code steps across 88 flows

Metadata

Metadata

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