Fix impossible function cron schedules#12416
Conversation
Greptile SummaryThis PR fixes a crashloop in the function scheduler caused by cron expressions that are syntactically valid but impossible to execute (e.g.,
Confidence Score: 5/5Safe to merge — the change is minimal and targeted, touching only the validation path and the scheduler's exception-handling block. Both code sites are straightforward: the validator adds a single try/catch around an existing library call, and the scheduler moves one line inside an already-guarded block. The new test cases directly cover the happy path and the failure path introduced by this change. No existing behavior is removed or altered beyond expanding the set of expressions that are treated as invalid. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "Revert "Fix deployment cancel race in bu..." | Re-trigger Greptile |
✨ Benchmark resultsComparing 1.9.x (before) to fix/schedule-functions-impossible-cron (after). Before
After
Delta
Top API waits
|
What does this PR do?
Prevents impossible function cron expressions from crashlooping the function scheduler.
The cron library can parse expressions like
*/5 22-3 * * *, but later throwsRuntimeException: Impossible CRON expressionwhen calculating the next run date. This PR validates cron expressions by calculating the next run date and makes the function scheduler silently skip impossible legacy schedules.Test Plan
vendor/bin/phpunit tests/unit/Task/Validator/CronTest.php --display-warningscomposer lint src/Appwrite/Task/Validator/Cron.phpcomposer lint src/Appwrite/Platform/Tasks/ScheduleFunctions.phpcomposer lint tests/unit/Task/Validator/CronTest.phpNote: The targeted PHPUnit run passes assertions but reports a warning from
dragonmantank/cron-expressionwhile evaluating the intentionally invalid wrapped-hour expression.Related PRs and Issues
Checklist