openclaw - ✅(Solved) Fix [Bug]: Cron schedule object format not accepted (contradicts documentation) [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50942Fetched 2026-04-08 01:06:23
View on GitHub
Comments
2
Participants
2
Timeline
14
Reactions
0
Timeline (top)
referenced ×9commented ×2labeled ×2cross-referenced ×1

Cron configuration with object format {"schedule": {"kind": "cron", "expr": "..."}} is rejected by gateway with error "invalid cron schedule: expr is required", despite documentation stating both simple and object formats are supported.

Error Message

Error log from gateway:

Error: invalid cron schedule: expr is required File: ~/.openclaw/cron/jobs.json Occurrences: 2026-03-20 14:36, 15:35, 16:07 (3 times)

Documentation reference: https://docs.openclaw.ai/automation/cron-jobs

Root Cause

Cron configuration with object format {"schedule": {"kind": "cron", "expr": "..."}} is rejected by gateway with error "invalid cron schedule: expr is required", despite documentation stating both simple and object formats are supported.

Fix Action

Fix / Workaround

Affected: All users trying to use cron jobs with object format Severity: Medium (cron jobs fail, but simple format workaround exists) Frequency: 100% reproducible (3/3 observed attempts) Consequence: Cron jobs cannot use documented object format, requires manual intervention to fix configuration repeatedly

Temporary workaround: Use simple format {"schedule": "30 9 * * *"} and regularly check if configuration has been modified.

PR fix notes

PR #50994: fix(cron): preserve empty expr field instead of silently deleting

Description (problem / solution / changelog)

Summary

Fixes issue #50942 where { kind: "cron", expr: "" } had the expr field silently deleted by coerceSchedule(), causing "invalid cron schedule: expr is required" at runtime.

Root Cause

In src/cron/normalize.ts coerceSchedule():

if (normalizedExpr) {
  next.expr = normalizedExpr;
} else if ("expr" in next) {
  delete next.expr;  // BUG: deleted user's explicit empty expr
}

When user explicitly set expr: "", the else if branch deleted it, making the error message confusing.

Fix

Improved fix that addresses all review feedback:

if (normalizedExpr) {
  next.expr = normalizedExpr;
} else if ("expr" in next) {
  if (typeof next.expr !== "string" || next.kind !== "cron") {
    delete next.expr;
  } else {
    // Preserve empty-string expr for cron kind (triggers validation error),
    // but normalize whitespace-only to empty string so minLength check catches it.
    next.expr = "";
  }
}
  • Cron with "": expr preserved → clear validation error
  • Cron with whitespace: normalized to "" → minLength validation catches it
  • Non-string expr: deleted
  • Non-cron types (at/every): blank expr deleted before schema validation

Test Plan

  • All 521 cron tests pass
  • Added 6 regression tests covering all edge cases
  • 36/36 normalize tests pass

🤖 Generated with Claude Code

Changed files

  • src/cron/normalize.test.ts (modified, +102/-0)
  • src/cron/normalize.ts (modified, +7/-1)

Code Example

Error log from gateway:

Error: invalid cron schedule: expr is required
File: ~/.openclaw/cron/jobs.json
Occurrences: 2026-03-20 14:36, 15:35, 16:07 (3 times)


Documentation reference: https://docs.openclaw.ai/automation/cron-jobs
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

Cron configuration with object format {"schedule": {"kind": "cron", "expr": "..."}} is rejected by gateway with error "invalid cron schedule: expr is required", despite documentation stating both simple and object formats are supported.

Steps to reproduce

  1. Create a cron job with object format configuration in ~/.openclaw/cron/jobs.json: {"schedule": {"kind": "cron", "expr": "30 9 * * *"}}
  2. Save the configuration
  3. Restart gateway with: openclaw gateway restart
  4. Gateway refuses to load configuration

Expected behavior

According to official documentation (https://docs.openclaw.ai/automation/cron-jobs), both simple format ("schedule": "30 9 * * *") and object format ("schedule": {"kind": "cron", "expr": "30 9 * * *"}) should be accepted.

Actual behavior

Gateway rejects object format configuration with error: "Error: invalid cron schedule: expr is required". Only simple format works. The configuration gets automatically converted to object format (possibly by internal tool/script), causing cron jobs to fail repeatedly.

OpenClaw version

2026.3.13

Operating system

Windows 10

Install method

npm install -g openclaw@latest

Model

bailian/qwen3.5-plus

Provider / routing chain

bailian (DashScope)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Error log from gateway:

Error: invalid cron schedule: expr is required
File: ~/.openclaw/cron/jobs.json
Occurrences: 2026-03-20 14:36, 15:35, 16:07 (3 times)


Documentation reference: https://docs.openclaw.ai/automation/cron-jobs

Impact and severity

Affected: All users trying to use cron jobs with object format Severity: Medium (cron jobs fail, but simple format workaround exists) Frequency: 100% reproducible (3/3 observed attempts) Consequence: Cron jobs cannot use documented object format, requires manual intervention to fix configuration repeatedly

Additional information

This issue was discovered while setting up daily learning tasks. The configuration keeps getting converted to object format (possibly by some internal OpenClaw tool/script), causing the cron jobs to fail repeatedly.

Temporary workaround: Use simple format {"schedule": "30 9 * * *"} and regularly check if configuration has been modified.

Suggestions:

  1. If object format is not yet implemented, please clarify in documentation that only simple format is currently supported
  2. If object format should be supported, please fix the configuration parsing logic
  3. Add configuration validation to prevent automatic conversion to invalid format

extent analysis

Fix Plan

To resolve the issue with the cron configuration object format being rejected, we need to update the configuration parsing logic to support both simple and object formats.

Here are the steps to fix the issue:

  • Update the cron.js file in the OpenClaw gateway to parse the object format correctly.
  • Add configuration validation to prevent automatic conversion to an invalid format.

Example code changes:

// cron.js
const parseCronSchedule = (schedule) => {
  if (typeof schedule === 'string') {
    // Simple format, already supported
    return schedule;
  } else if (typeof schedule === 'object' && schedule.kind === 'cron' && schedule.expr) {
    // Object format, return the expr
    return schedule.expr;
  } else {
    throw new Error('Invalid cron schedule: expr is required');
  }
};

Verification

To verify that the fix worked:

  1. Update the cron.js file with the new parsing logic.
  2. Restart the OpenClaw gateway.
  3. Create a new cron job with the object format configuration in ~/.openclaw/cron/jobs.json.
  4. Verify that the gateway loads the configuration without errors.
  5. Check that the cron job runs as scheduled.

Extra Tips

  • Make sure to update the documentation to reflect the supported formats.
  • Consider adding automated tests to ensure that both simple and object formats are working correctly.
  • If the issue persists, check the internal tool/script that is converting the configuration to object format and update it to use the correct format.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

According to official documentation (https://docs.openclaw.ai/automation/cron-jobs), both simple format ("schedule": "30 9 * * *") and object format ("schedule": {"kind": "cron", "expr": "30 9 * * *"}) should be accepted.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Cron schedule object format not accepted (contradicts documentation) [1 pull requests, 2 comments, 2 participants]