Skip to content

Argo Workflows Loop Quick Fix - With Items Iteration Errors

DodaTech Updated 2026-06-26 1 min read

Argo Workflows loops with withItems iterate over a list of items, running a template for each. Incorrect loop syntax or item formatting causes partial execution. This guide covers the fix.

Quick Fix

Wrong

- name: process
  template: process-item
  withItems:
    - item1
    - item2
    - item3

The issue: Process-item template does not receive the item value. The {{item}} reference in the template will be empty because templates must declare inputs.parameters to receive loop items.

- name: process
  template: process-item
  arguments:
    parameters:
    - name: item
      value: "{{item}}"
  withItems:
    - item1
    - item2
    - item3
---
- name: process-item
  inputs:
    parameters:
    - name: item
  container:
    image: alpine:latest
    command: ["/bin/sh", "-c"]
    args: ["echo 'processing {{inputs.parameters.item}}'"]
# Expected output after applying the fix
# processing item1
# processing item2
# processing item3
# All 3 iterations complete in parallel
# Status: Succeeded

Prevention

  • Always pass {{item}} as an argument to the loop template
  • Declare parameter in the loop template's inputs.parameters
  • Use withParam: "{{inputs.parameters.items}}" for dynamic lists
  • Set maxDuration for loops with many iterations
  • Monitor loop progress with argo get <workflow>

DodaTech Tools

Doda Browser's loop inspector shows iteration progress and per-item status. DodaZIP archives loop results for batch processing analysis. Durga Antivirus Pro detects infinite loop patterns in workflow definitions.

FAQ

What is the difference between withItems and withParam?

withItems takes a static list in the YAML. withParam takes a JSON array from a parameter, enabling dynamic iteration from upstream step outputs. ||| Can I access the loop index inside the template? Yes, use {{item.index}} and {{item.key}} for indexed iteration. The index is automatically available when iterating over JSON objects. ||| How many items can I iterate over in a single loop? Argo does not enforce a hard limit, but very large loops (1000+) may cause performance issues. Consider using fan-out patterns for large batch processing.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro