Skip to content

action_loop's until: condition is never evaluated — the loop always runs once #476

Description

@jeremymanning

An action_loop step must declare until: or while_condition: — the compiler rejects it otherwise:

YAMLCompilerError: action_loop must have either 'until' or 'while_condition'

The condition is then never used. Run, hermetically:

- id: loop
  action_loop:
    - action: filesystem
      parameters: {action: write, path: "out/{{ iteration }}.txt", content: "x"}
  until: "false"
  max_iterations: 4

Expected: 4 iterations (until never satisfied, capped by max_iterations). Observed: 1 iteration, one file. until: "{{ iteration >= 3 }}" also gives 1. So does until: "{{ zzz_nosuch_variable }}" — a name that exists nowhere raises nothing, which is the giveaway: the string is never rendered or evaluated.

_check_termination_condition (control_flow/action_loop_handler.py:392) is written correctly — it builds an eval context from loop_context.to_template_dict() and calls the condition evaluator. Something above it is not reaching that path, or is terminating first.

Consequence for validation: templates in an action_loop's until: are dead text. core/loop_contracts.py currently validates them in the loop's body scope, which is the right answer if the field is ever evaluated, and harmless (no false rejection) if it is not. That choice should be revisited once this is fixed.

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