chenhg5/cc-connect · error
ErrCronJobNotFound
ErrCronJobNotFound
Error message
%w: %q
What it means
RunJobNow looks up the persisted cron job by id; if the store has no job with that id it returns ErrCronJobNotFound wrapped with the quoted id. Manual runs use the same store as scheduled runs, so unknown or deleted ids fail synchronously with this sentinel error.
Source
Thrown at core/cron.go:667
}
cs.entries[jobID] = entryID
return nil
}
func (cs *CronScheduler) executeJob(jobID string) {
job := cs.store.Get(jobID)
if job == nil {
return
}
cs.runJob(job, false)
}
// RunJobNow triggers a persisted cron job immediately in the background.
// Disabled jobs are allowed to run manually; only scheduled executions enforce Enabled.
func (cs *CronScheduler) RunJobNow(id string) error {
job := cs.store.Get(id)
if job == nil {
return fmt.Errorf("%w: %q", ErrCronJobNotFound, id)
}
cs.mu.RLock()
_, ok := cs.engines[job.Project]
cs.mu.RUnlock()
if !ok {
return fmt.Errorf("%w: %q", ErrCronProjectNotFound, job.Project)
}
snapshot := *job
go cs.runJob(&snapshot, true)
return nil
}
func (cs *CronScheduler) runJob(job *CronJob, manual bool) {
if job == nil {
return
}
if !manual && !job.Enabled {
returnView on GitHub (pinned to 4000b2338a)
Solutions
- List current jobs (handleCron listing) and use a valid id
- Use errors.Is(err, core.ErrCronJobNotFound) to return a friendly 'job not found' message to the user
- If the id should exist, check that the daemon is pointed at the expected store file
Example fix
// before
if err := cs.RunJobNow(id); err != nil { return err }
// after
if err := cs.RunJobNow(id); err != nil {
if errors.Is(err, core.ErrCronJobNotFound) {
return fmt.Errorf("cron job %q does not exist; use /cron list", id)
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
if cs.Store().Get(id) == nil { return fmt.Errorf("job %q not found", id) } Try / catch
if err := cs.RunJobNow(id); err != nil {
if errors.Is(err, core.ErrCronJobNotFound) {
reply("cron job not found: " + id)
return nil
}
return err
} Prevention
- Always list jobs to obtain fresh ids; never reuse ids from old listings
- Treat ErrCronJobNotFound via errors.Is rather than string matching
When it happens
Trigger: Calling RunJobNow with an id that was never created, was deleted via a remove/edit flow, or a typo'd/stale id from handleCronExec or cmdCronExec.
Common situations: User runs a /cron exec command with an id copied from an old listing; the job was removed by another session before the manual trigger arrives.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- job %q not found
- ErrCronProjectNotFound
- cron job not found
- cron project not found
- pi: session %q not found
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/878424957f0f4ff1.
Report an issue: GitHub.