fix(foundation): pre-validate cron expressions to prevent runtime panics (#1476)#1533
fix(foundation): pre-validate cron expressions to prevent runtime panics (#1476)#1533SH20RAJ wants to merge 1 commit intomofa-org:mainfrom
Conversation
|
Hi! This PR adds pre-validation for cron expressions in the |
|
Addressing Issue #1476. This PR ensures that invalid cron expressions are caught early during task registration in |
|
All checks are green here as well. I aimed for a minimal reliability fix: validate cron expressions at registration time so misconfigurations fail fast instead of panicking later in the scheduler. If maintainers would rather place that validation at a different boundary, I can update it quickly. |
This PR addresses a critical stability issue where invalid cron expressions could cause background tasks to panic at runtime.
Changes
CronScheduler::add_taskto returnResultand pre-validate expressions using thecroncrate..unwrap()with proper error propagation in the scheduler registration phase.Verification
cargo test -p mofa-foundation --lib scheduler::cron::testspassed."* * * * * * *"(invalid) now returns an error instead of panicking.Motivation
Improves production reliability by ensuring that misconfigured periodic tasks fail fast at registration rather than crashing the runtime later. (GSoC 2026: Idea 16 related).