GitHub Actions format() placeholder index out of range
format(string, a, b, ...) substitutes {0}, {1}, ... with its positional arguments. Referencing a placeholder index higher than the number of supplied arguments is an evaluation error.
What this error means
An expression using format() fails to evaluate with an index/placeholder out-of-range error.
Error: The format string references index 2 but only 2 arguments were supplied (indexes 0 and 1).
run-name: ${{ format('{0} on {1} by {2}', github.workflow, github.ref_name) }}Common causes
More placeholders than arguments
A {2} placeholder needs a third argument; supplying only two triggers the out-of-range error.
Off-by-one from zero-based indexing
Placeholders are zero-based, so {1} is the second argument; treating them as one-based shifts everything.
How to fix it
Supply an argument for every placeholder
- Count placeholders and pass exactly that many arguments in order.
- Remember indexing starts at {0}.
run-name: ${{ format('{0} on {1} by {2}', github.workflow, github.ref_name, github.actor) }}Escape literal braces
- To print a literal brace, double it as {{ or }}.
- This prevents an accidental placeholder reference.
How to prevent it
- Match placeholder count to argument count before committing.
- Recall placeholders are zero-based.