GitHub Actions startsWith expects a string but received null
startsWith(searchString, searchValue) requires string arguments. When a referenced context value is unset it resolves to null, and passing null where a string is expected produces an evaluation error or an always-false condition.
What this error means
An expression using startsWith fails to evaluate or behaves as always-false when the input context value is missing.
github-actions
Error: Unexpected value 'null'. startsWith expects a string but received null.
if: startsWith(github.event.head_commit.message, 'release:')Common causes
Context value absent for this event
Fields like head_commit.message exist only for certain events; on others they are null.
Typo or wrong context path
A misspelled context path resolves to null, which startsWith rejects as a non-string.
How to fix it
Coerce to a string before comparing
- Wrap the argument so a null becomes an empty string before startsWith runs.
- Use format() or a fallback expression to guarantee a string.
.github/workflows/ci.yml
if: ${{ startsWith(format('{0}', github.event.head_commit.message), 'release:') }}Guard on the event type first
- Add a condition that only references the field for events that provide it.
- Combine with && so the startsWith only runs when the value exists.
How to prevent it
- Assume event-specific context fields may be null on other triggers.
- Wrap optional strings with format() or a default before string functions.
Related guides
GitHub Actions contains() returns unexpected results from a type mismatch in an ifFix an if condition where contains() compares mismatched types (number vs string, array vs scalar) and evalua…
GitHub Actions "Unrecognized named-value" - Fix Expression/Context ErrorsFix GitHub Actions "Unrecognized named-value" and expression errors - referencing a context that is not avail…
GitHub Actions join() called on a non-array valueFix a join() expression that errors because its first argument is a scalar or null instead of an array.