Skip to content

[Bug]: Ineffective monitoring for failing cron jobs #28861

@arkulkarni

Description

@arkulkarni

Summary

Cron jobs created via an earlier version of OpenClaw store the schedule expression as "cron": "..." in jobs.json. The current scheduler expects "expr": "...". When the scheduler tries to compute the next run time, it throws:

TypeError: Cannot read properties of undefined (reading 'trim')

This silently prevents all affected jobs from ever firing. The error is stored in state.lastError as "schedule error: TypeError: Cannot read properties of undefined (reading 'trim')" but nothing alerts the user.

Suggested fix
In service/store.ts ensureLoaded(), add migration: if sched.cron is a string and sched.expr is missing, set sched.expr = sched.cron and delete sched.cron.

Additional context
Also affects: jobId field (schema expects id) and missing wakeMode. No active monitoring alerts the user when scheduler errors occur — the failure is completely silent.

Steps to reproduce

  1. Have a jobs.json with schedule: { kind: "cron", cron: "20 6 * * *", tz: "..." }
  2. Start the gateway
  3. Scheduled jobs never fire; state.scheduleErrorCount increments silently

Expected behavior

Either: (a) the store migration in service/store.ts ensureLoaded() renames cron → expr automatically, OR (b) computeNextRunAtMs() in schedule.ts guards against schedule.expr being undefined instead of calling .trim() directly.

Actual behavior

silent failure

OpenClaw version

2026.2.21

Operating system

Ubuntu on docker

Install method

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions