{"record":{"id":"d965c7b43877a1e2","repo":"chenhg5/cc-connect","slug":"invalid-cron-expression-q-w","errorCode":null,"errorMessage":"invalid cron expression %q: %w","messagePattern":"invalid cron expression %q: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"core/cron.go","lineNumber":487,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\tcs.cron.Start()\n\tslog.Info(\"cron: scheduler started\", \"jobs\", len(jobs))\n\treturn nil\n}\n\nfunc (cs *CronScheduler) Stop() {\n\tcs.cron.Stop()\n}\n\nfunc (cs *CronScheduler) AddJob(job *CronJob) error {\n\tif err := validateCronJob(job); err != nil {\n\t\treturn err\n\t}\n\tjob.SessionMode = NormalizeCronSessionMode(job.SessionMode)\n\tif _, err := cron.ParseStandard(job.CronExpr); err != nil {\n\t\treturn fmt.Errorf(\"invalid cron expression %q: %w\", job.CronExpr, err)\n\t}\n\tif err := cs.store.Add(job); err != nil {\n\t\treturn err\n\t}\n\tif job.Enabled {\n\t\treturn cs.scheduleJob(job)\n\t}\n\treturn nil\n}\n\nfunc (cs *CronScheduler) RemoveJob(id string) bool {\n\tcs.mu.Lock()\n\tif entryID, ok := cs.entries[id]; ok {\n\t\tcs.cron.Remove(entryID)\n\t\tdelete(cs.entries, id)\n\t}\n\tcs.mu.Unlock()\n\treturn cs.store.Remove(id)","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/cron.go#L469-L505","documentation":"AddJob validates the job then parses job.CronExpr with robfig/cron's ParseStandard; a syntax-invalid expression produces this wrapped error containing the original parse failure. The job is not stored or scheduled.","triggerScenarios":"CronScheduler.AddJob with a CronExpr that fails standard 5-field cron parsing, e.g. \"99 9 * * *\", \"* * *\", or containing invalid characters/step values.","commonSituations":"Hand-written cron expressions with out-of-range minute/hour values; expressions copied from systems using 6-field (seconds) syntax; missing a field entirely.","solutions":["Fix the cron expression to standard 5-field syntax (minute hour dom mon dow), e.g. \"0 9 * * *\".","Check the wrapped %w error for the exact offset/token that failed to parse.","Validate locally with cron.ParseStandard before calling AddJob."],"exampleFix":"// before\njob.CronExpr = \"99 9 * * *\"\n// after\njob.CronExpr = \"59 9 * * *\"","handlingStrategy":"validation","validationCode":"if _, err := cron.ParseStandard(expr); err != nil { return err }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate expressions with cron.ParseStandard before AddJob.","Stick to standard 5-field cron syntax.","Offer users a picker/validator in chat commands instead of free text."],"tags":["go","cron","validation"],"backgroundTag":"invalid-cron-expression","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}