Skip to content
Latchkey

GitHub Actions "startsWith ... wrong argument type" in CI

startsWith and endsWith compare two strings. Passing a null context value, an object, or an array makes the expression evaluate to an unexpected result or fail, because the argument is not a string.

What this error means

An if using startsWith(...) never matches as expected, or the run reports a type problem, when one argument is a context that resolves to null or to a non-string.

GitHub Actions
Error: Unexpected type of value '' for parameter 'searchString' in startsWith()

Common causes

A context resolves to null

A field like github.event.pull_request.title can be null on non-PR events, so startsWith gets a non-string first argument.

An object or array passed instead of a string

Handing github.event or a JSON array to startsWith violates its string-only signature.

How to fix it

Coerce to a string and guard for null

  1. Wrap the value so it is always a string, e.g. format('{0}', x).
  2. Add an event guard so the field exists before comparing.
  3. Re-run the workflow.
.github/workflows/ci.yml
if: ${{ startsWith(format('{0}', github.ref), 'refs/tags/') }}

Use the right field for the event

Reference a field that is always a string for the triggering event, such as github.ref instead of a PR-only field.

How to prevent it

  • Assume PR-only fields are null on push events.
  • Use format() to coerce values before string functions.
  • Test if conditions across the events that can trigger them.

Frequently asked questions

What causes ""startsWith()" wrong argument type"?
A field like github.event.pull_request.title can be null on non-PR events, so startsWith gets a non-string first argument.
How do I fix "startsWith()" wrong argument type?
Coerce to a string and guard for null

Related guides

References

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