Skip to content

Cron job manual execution fails with TypeError: Cannot read properties of undefined (reading 'startsWith') #68221

Description

@easonfu23

OpenClaw Cron Job Issue Report

Issue Title

Cron job manual execution fails with TypeError: Cannot read properties of undefined (reading 'startsWith')

Issue Body

Describe the bug
When manually executing a cron job from the OpenClaw Control UI, the job fails with the error:

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

To Reproduce
Steps to reproduce the behavior:

  1. Create a cron job in /home/node/.openclaw/cron/jobs.json with the following configuration:
{
  "version": 1,
  "jobs": [
    {
      "id": "daily-news-001",
      "name": "daily-news-morning",
      "description": "每日新闻摘要(早间版)",
      "enabled": true,
      "createdAtMs": 1776530000000,
      "updatedAtMs": 1776530000000,
      "runTimeoutSeconds": 900,
      "schedule": {
        "kind": "cron",
        "expr": "30 8 * * *",
        "tz": "Asia/Shanghai"
      },
      "sessionTarget": "default",
      "wakeMode": "now",
      "payload": {
        "kind": "agentTurn",
        "message": "使用 Tavily Search 搜索每日新闻:国际热点,体育热点,科技热点,社会热点。整理成结构化摘要后发送到飞书。"
      },
      "delivery": {
        "mode": "push"
      },
      "state": {
        "nextRunAtMs": 1776529800000
      }
    }
  ]
}
  1. Go to OpenClaw Control UI → Cron Jobs tab
  2. Click the "Execute" button to manually run the job
  3. See error: TypeError: Cannot read properties of undefined (reading 'startsWith')

Expected behavior
The cron job should execute successfully and send the news summary to the target channel.

Actual behavior
The job is skipped with the error message and status shows "未知" (unknown).

Environment

  • OpenClaw version: 2026.4.15 (latest)
  • Operating system: Linux (Docker container)
  • Node version: v24.14.0

Additional context

  • The JSON configuration is valid (verified with python3 -c "import json; json.load(open('jobs.json'))")
  • The sessionTarget field is set to "default" as required
  • The delivery mode is set to "push"
  • Restarting the gateway (openclaw gateway restart) does not resolve the issue
  • The error appears to originate from internal code that calls .startsWith() on an undefined variable
  • This affects all cron jobs, not just a specific one

Possible root cause
Looking at the error message, it seems like the internal code is trying to call .startsWith() method on a variable that is undefined. This could be:

  1. sessionTarget validation logic
  2. payload format validation
  3. agentId parsing logic

Screenshot
N/A (error message: "daily-news-digest-002 · 已跳过 TypeError: Cannot read properties of undefined (reading 'startsWith') 未知")


Labels to add

  • bug
  • cron
  • needs-triage

Repository

https://github.com/openclaw/openclaw

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions