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.
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.
# 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.
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.