GitHub Actions "The expression contains invalid characters" in CI
The expression tokenizer accepts a limited character set. A smart quote pasted from a document, a non-ASCII dash, or a stray symbol inside ${{ }} is rejected as an invalid character.
What this error means
The run fails with "Invalid workflow file" and a message that the expression at the given position contains invalid characters, often after copying an expression from a chat or doc.
GitHub Actions
Invalid workflow file: .github/workflows/ci.yml
(Line: 10, Col: 13): The expression contains invalid charactersCommon causes
Smart quotes pasted into the expression
Curly quotes replace the straight ' or " that the tokenizer expects inside string literals.
A non-ASCII symbol inside the braces
An en/em dash, non-breaking space, or other unicode punctuation slipped into the expression.
How to fix it
Retype the expression with plain ASCII
- Delete the expression and retype it by hand.
- Use straight quotes and a plain hyphen if needed.
- Re-run the workflow.
.github/workflows/ci.yml
# replace curly quotes with straight quotes
if: ${{ github.ref == 'refs/heads/main' }}Strip non-ASCII characters from the file
Search the workflow for non-ASCII bytes and replace them.
Terminal
grep -nP '[^\x00-\x7F]' .github/workflows/ci.ymlHow to prevent it
- Disable smart-quote substitution in your editor for code.
- Avoid pasting expressions from rich-text sources.
- Lint for non-ASCII characters in workflow files.
Related guides
GitHub Actions "Unexpected end of expression" in CIFix GitHub Actions "Unexpected end of expression" in CI - a `${{ }}` expression is missing a closing brace, p…
GitHub Actions "Unrecognized named-value: 'env'" in CIFix GitHub Actions "Unrecognized named-value: 'env'" in CI - an expression referenced the `env` context where…
GitHub Actions "fromJSON ... Unable to parse" in CIFix GitHub Actions "Unable to parse" from fromJSON in CI - the string handed to fromJSON was not valid JSON,…