Skip to content

[Bug]: Expression evaluation errors abort the workflow run instead of failing the step #5620

Backlog

Description

@markuswondrak

Bug Description

When a workflow step's expression fails to evaluate, the ValueError escapes Step.execute(), and the whole run aborts. For example, {{ inputs.x | from_json }} with invalid JSON does this. continue_on_error: true is ignored, and the exception text is written to state.json and log.jsonl (workflow_failed).

design/workflow-step.md ("Step contract") says steps should return a failed StepResult rather than raise an unhandled exception. The engine has no step-level conversion: execute_step calls impl.execute(config, context) without a try (src/specify_cli/workflows/_execution.py). The only catch is the run-level except Exception in WorkflowEngine (engine.py), which fails the run and re-raises.

Some steps catch these errors per field: the shell step for env and the github step. The command and prompt steps do not, for input, integration, or model, and neither do the shared dispatch settings (_dispatch_settings.resolve_dispatch_settings). About 25 evaluate_expression calls in the built-in steps are mostly unprotected.

Found during review of #5616 (review comment: #5616 (comment)). That PR handles only its new additional_context field locally, because that field must never put its value in an error message. The general behavior is pre-existing and tracked here.

Steps to Reproduce

Run on main at f2010547 in a project with any integration installed:

schema_version: "1.0"
workflow: { id: expr-error, name: Expression error, version: "0.0.1" }
inputs:
  x: { type: string, default: "not-json" }
steps:
  - id: a
    command: speckit.plan
    integration: claude
    continue_on_error: true
    input:
      args: "{{ inputs.x | from_json }}"
  - id: b
    type: shell
    run: echo second-step-ran

specify workflow run expr-wf.yml

Expected Behavior

Step a fails with a step error. Because of continue_on_error: true, step b runs, and the run completes.

Actual Behavior

Workflow failed: from_json: invalid JSON: Expecting value: line 1 column 1 (char 0)

Step b never runs. log.jsonl ends with {"event": "workflow_failed", "error": "from_json: invalid JSON: ..."}.

Some filter messages include the evaluated value, for example from_json: invalid JSON constant: {value} in expressions/filters.py. With the current behavior that value goes into log.jsonl.

Specify CLI Version

1.4.6.dev0 (main at f2010547)

AI Agent

Not agent-specific (reproduced with the claude integration; the failure happens before dispatch).

Operating System

Linux

Python Version

3.14

Additional Context

A single fix point is available: in execute_step, convert a ValueError from impl.execute() into a failed StepResult. This makes the step contract hold for all step types and fields. Whether the message should include str(exc) needs a decision, because filter messages can contain evaluated values.

AI Disclosure

Filed on behalf of @markuswondrak by the pi coding agent (provider github-copilot, model claude-opus-5.5, reasoning effort xhigh, interactive and human-supervised). The agent read the code, reproduced the behavior on main with the workflow above, and wrote this issue at @markuswondrak's request.

Activity

  1. added
    triage-must-have
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-must-have

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions