GitHub Actions "The identifier is invalid" for a job id
Job ids must start with a letter or underscore and contain only alphanumerics, hyphens, and underscores. An invalid id fails validation.
What this error means
The workflow is rejected with "The identifier '<id>' is invalid" naming the offending job key.
github-actions
The workflow is not valid. .github/workflows/ci.yml (Line: 6): The identifier '2-build' is invalid. IDs may only contain alphanumeric characters, '_', and '-'. IDs must start with a letter or '_'.Common causes
Job id starts with a digit
A leading number such as 2-build is not a valid identifier.
Disallowed characters
Spaces, dots, or slashes in the job key are not permitted.
How to fix it
Rename the job to a valid id
- Start the id with a letter or underscore.
- Use only letters, digits, hyphens, and underscores.
- Update any needs: references to the new id.
.github/workflows/ci.yml
jobs:
build-2:
runs-on: ubuntu-latest
steps:
- run: makeHow to prevent it
- Adopt a naming convention that always begins job ids with a letter.
- Run actionlint, which validates identifier rules.
Frequently asked questions
What causes ""The identifier 'X' is invalid""?
A leading number such as 2-build is not a valid identifier.
How do I fix "The identifier 'X' is invalid"?
Rename the job to a valid id
Related guides
GitHub Actions two jobs with the same idFix the GitHub Actions error caused by two jobs sharing the same id, which YAML treats as a duplicate mapping…
GitHub Actions "needs job X but it is not defined"Fix the GitHub Actions error where a job needs another job that is not defined, usually a typo in the job id…
GitHub Actions "Unexpected value" at a specific workflow lineFix the GitHub Actions "The workflow is not valid ... (Line: N): Unexpected value" error caused by a key in t…