Skip to content

[Feature Request] Validate step references at flow load time #44

Description

@ameet

Problem

In One CLI flows, code steps can reference $.steps.X where step X either doesn't exist or is declared after the referencing step. No error is raised at flow load or validation time — the reference silently resolves to undefined at runtime.

How We Discovered This

We found 7 flows where buildCacheEntry referenced $.steps.buildResult, but buildResult was declared AFTER buildCacheEntry in the steps array:

{
  "steps": [
    { "id": "buildCacheEntry", "type": "code", "code": { "source": "var result = $.steps.buildResult ? $.steps.buildResult.output : null; ..." } },
    { "id": "writeCacheFile", "type": "file-write", ... },
    { "id": "buildResult", "type": "code", ... }
  ]
}

Since One CLI executes steps sequentially by declaration order, buildCacheEntry always sees $.steps.buildResult as undefined. The quality gate if (!result) return null always triggers, and caching silently never works. Every flow invocation re-computes expensive LLM calls that should have been cached.

This affected 7 flows in our codebase and went undetected until we wrote a custom static analysis script.

Proposed Solutions

Option A (best): At one flow execute time, before execution begins, scan all code step sources for $.steps.X references and validate:

  1. Step X exists in the flow's step list
  2. Step X is declared before the referencing step (or flag as "forward reference — may be undefined at runtime")

Option B: Add a one flow validate command (or enhance existing validation) that performs static step reference analysis and reports warnings.

Option C: At runtime, when a code step accesses $.steps.X and X hasn't executed yet, log a warning: "Step 'buildCacheEntry' references 'buildResult' which hasn't executed yet — value will be undefined."

Impact

Forward-reference bugs cause silent failures (caching broken, data missing, quality gates bypassed) that are extremely difficult to debug because no error is raised. Seven flows in our 88-flow codebase had this bug, potentially wasting significant LLM compute on every invocation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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