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.
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
- Wrap the value so it is always a string, e.g.
format('{0}', x). - Add an event guard so the field exists before comparing.
- Re-run the workflow.
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
ifconditions across the events that can trigger them.