Skip to content
Latchkey

GitHub Actions format() Error - Placeholder Out of Range or Bad Braces

A format() call references a placeholder index that has no matching argument, or contains literal { / } that were not escaped, so the expression fails to evaluate.

What this error means

The workflow fails to compile or a step errors when evaluating a format() expression, complaining about the format string or an index outside the supplied arguments.

.github/workflows/ci.yml
# {2} has no third argument (only {0} and {1} are supplied)
name: ${{ format('{0}-{1}-{2}', github.ref_name, github.sha) }}

Common causes

Placeholder index beyond the arguments

format() uses zero-based indices. {2} requires a third argument; supplying only two makes the index out of range.

Unescaped literal braces

A literal { or } in the format string is interpreted as a placeholder. To emit a real brace you must double it as {{ or }}.

How to fix it

Match indices to the arguments

.github/workflows/ci.yml
name: ${{ format('{0}-{1}', github.ref_name, github.sha) }}

Escape literal braces by doubling

Use {{ and }} when you need a literal brace in the output.

.github/workflows/ci.yml
run: echo "${{ format('result is {{{0}}}', steps.calc.outputs.value) }}"

How to prevent it

  • Count placeholders and arguments before relying on format().
  • Double any literal braces inside the format string.
  • Prefer plain string concatenation for simple cases where format() adds no clarity.

Frequently asked questions

What causes "format() error"?
format() uses zero-based indices. {2} requires a third argument; supplying only two makes the index out of range.
How do I fix format() error?
Match indices to the arguments

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card