Step alias rendering raises SyntaxError when the step's if condition is false
Description
When a step defines both an alias block and an if condition, the alias
expressions are currently rendered before the if condition is
evaluated. If the step is meant to be skipped (its if evaluates to
false) and one of its alias expressions references the result of another
step that was itself skipped (and therefore has no result in the
context), rendering that alias produces broken output — e.g. a template
like:
keep.dictget({{ steps.get-incident.results.body }}, 'user_generated_name', 'Untitled incident')
renders steps.get-incident.results.body as an empty string, turning
the expression into the syntactically invalid keep.dictget(, 'user_generated_name', 'Untitled incident').
This raises a SyntaxError and aborts the workflow step entirely,
instead of the step being cleanly skipped as the if condition intends.
Steps to reproduce
- Define a step with an
if condition that evaluates to false because
it depends on the result of another step that was skipped.
- Give that step an
alias whose expression references the same
skipped step's result.
- Run the workflow.
Expected behavior
The step should be skipped without error — aliases should only be
evaluated once it's known the step will actually run.
Actual behavior
A SyntaxError is raised while rendering the alias expression, because
it's evaluated unconditionally before the if check.
Relevant code
keep/step/step.py, in Step._run_single — aliases are rendered and set
into the context near the top of the method, before the if condition
is checked further down.
Step alias rendering raises SyntaxError when the step's
ifcondition is falseDescription
When a step defines both an
aliasblock and anifcondition, the aliasexpressions are currently rendered before the
ifcondition isevaluated. If the step is meant to be skipped (its
ifevaluates tofalse) and one of its alias expressions references the result of another
step that was itself skipped (and therefore has no result in the
context), rendering that alias produces broken output — e.g. a template
like:
renders
steps.get-incident.results.bodyas an empty string, turningthe expression into the syntactically invalid
keep.dictget(, 'user_generated_name', 'Untitled incident').This raises a
SyntaxErrorand aborts the workflow step entirely,instead of the step being cleanly skipped as the
ifcondition intends.Steps to reproduce
ifcondition that evaluates to false becauseit depends on the result of another step that was skipped.
aliaswhose expression references the sameskipped step's result.
Expected behavior
The step should be skipped without error — aliases should only be
evaluated once it's known the step will actually run.
Actual behavior
A
SyntaxErroris raised while rendering the alias expression, becauseit's evaluated unconditionally before the
ifcheck.Relevant code
keep/step/step.py, inStep._run_single— aliases are rendered and setinto the context near the top of the method, before the
ifconditionis checked further down.