Skip to content
Latchkey

GitHub Actions join() called on a non-array value

join(array, separator) concatenates array elements into a string. Passing a scalar, object, or null where an array is expected is an evaluation error or yields the raw scalar rather than a joined list.

What this error means

An expression using join() fails to evaluate or returns an unexpected single value because its input was not an array.

github-actions
Error: join() expects an array as its first argument but received a string.
  run: echo "${{ join(github.event.head_commit.message, ', ') }}"

Common causes

Scalar passed instead of an array

join() needs an array; a single string or number is not iterable for joining.

fromJSON result was not an array

If the JSON parsed to an object or scalar, join() has nothing to iterate.

How to fix it

Pass an actual array

  1. Use an array-typed context value (e.g. github.event.commits) or build one with fromJSON.
  2. Confirm the value is a list, not an object or scalar.
.github/workflows/ci.yml
run: echo "${{ join(fromJSON('["a","b","c"]'), ', ') }}"

Wrap a single value before joining

  1. If you only have one value, there is nothing to join - reference it directly.
  2. For optional lists, default to an empty array via fromJSON(’[]’).

How to prevent it

  • Verify the argument to join() is an array type.
  • Default optional arrays to [] so join() never sees a scalar.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →