Skip to content

Argo Workflows Conditional Quick Fix - When Expression Errors

DodaTech Updated 2026-06-26 1 min read

Argo Workflows conditionals control whether steps execute based on runtime values. Incorrect when syntax causes unexpected step execution or skipping. This guide covers the fix.

Quick Fix

Wrong

- name: deploy
  template: deploy-app
  when: "{{workflow.parameters.branch}} == main"

The issue: when expression is missing quotes around the string comparison, and the parameter reference uses workflow-level syntax incorrectly. The expression evaluates to false or throws an error.

- name: deploy
  template: deploy-app
  when: "{{workflow.parameters.branch}} == 'main'"
  arguments:
    parameters:
    - name: branch
      value: "{{workflow.parameters.branch}}"
# Expected output after applying the fix
# When branch == 'main': deploy step executes
# When branch != 'main': deploy step skipped
# Status: Succeeded (or Skipped for deploy)
# Conditional logic works correctly

Prevention

  • Always quote string values in when expressions with single quotes
  • Use == for equality, != for inequality in when expressions
  • Reference parameters with proper {{workflow.parameters.*}} syntax
  • Combine conditions with && (AND) and || (OR) operators
  • Test conditional expressions with argo template lint

DodaTech Tools

Doda Browser's condition evaluator tests when expressions against sample parameter values. DodaZIP archives conditional branching decisions for audit. Durga Antivirus Pro validates condition expressions against injection.

FAQ

Can I use multiple conditions in a single when expression?

Yes, combine conditions with && for AND and || for OR. Example: "{{params.env}} == 'prod' && {{params.region}} == 'us-east1'". ||| What happens if a when expression references an undefined parameter? The expression evaluates to false and the step is skipped. Define all referenced parameters to avoid silent skips. ||| How do I negate a condition in Argo? Use != for inequality and ! prefix for boolean negation. Example: "{{params.skip_deploy}} != 'true'" or "!{{params.force}}".

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro