Skip to content
Latchkey

Invalid cron syntax in schedule ("Invalid workflow file") in CI

GitHub validates the schedule cron against POSIX cron syntax: exactly five fields (minute, hour, day-of-month, month, day-of-week). A missing field, an out-of-range value, or an unquoted * triggers an "Invalid workflow file" error.

What this error means

The workflow fails to load with "Invalid workflow file" and a message pointing at the cron value, or the schedule silently never runs because the expression is malformed.

GitHub Actions
Invalid workflow file: .github/workflows/nightly.yml
The workflow is not valid. .github/workflows/nightly.yml (Line: 4, Col: 15):
Invalid cron: '0 25 * *'  (only 4 fields, hour 25 out of range)

Common causes

Wrong number of fields

Cron needs five fields. 0 25 * * has four, and hour 25 is invalid; GitHub rejects it.

Unquoted expression breaks YAML

A leading * (like * 3 * * *) is a YAML alias character. The cron must be quoted, e.g. '0 3 * * *'.

How to fix it

Use five quoted fields in valid ranges

  1. Write minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-6).
  2. Quote the whole expression so YAML does not misread *.
  3. Validate with a cron checker before committing.
.github/workflows/nightly.yml
on:
  schedule:
    - cron: '0 3 * * *'   # 03:00 UTC daily

Fix out-of-range values

Correct any field outside its allowed range; hours are 0-23, not 1-24.

.github/workflows/nightly.yml
# wrong: '0 24 * * *'
# right: '0 0 * * *'   # midnight UTC

How to prevent it

  • Always quote cron expressions in YAML.
  • Keep to five fields and valid numeric ranges.
  • Validate cron with a linter or crontab.guru before pushing.

Frequently asked questions

What causes ""Invalid cron""?
Cron needs five fields. 0 25 * * has four, and hour 25 is invalid; GitHub rejects it.
How do I fix "Invalid cron"?
Use five quoted fields in valid ranges

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card