openclaw - ✅(Solved) Fix Bug: `openclaw cron list` throws TypeError: Cannot read properties of undefined (reading 'padEnd') [2 pull requests, 1 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#59968Fetched 2026-04-08 02:38:12
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
cross-referenced ×2commented ×1referenced ×1

Error Message

Running openclaw cron list throws the following error:

Fix Action

Workaround

Using openclaw cron list --json works correctly and returns the expected JSON data.

PR fix notes

PR #59978: CLI: tolerate malformed cron list rows

Description (problem / solution / changelog)

Summary

  • Problem: openclaw cron list could crash while rendering human-readable output if a persisted cron job row was malformed, even though the scheduler still loaded it.
  • Why it matters: the JSON path could still work, but the default CLI listing path crashed instead of degrading gracefully for legacy or partially invalid stored jobs.
  • What changed: hardened src/cli/cron-cli/shared.ts so row rendering falls back to placeholders for malformed string/state fields, and added regression coverage for missing name and id rows.
  • What did NOT change (scope boundary): this does not change cron storage, protocol validation, or repair malformed jobs on disk.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #59968
  • Related #59968
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: printCronList() assumed stored cron job fields like id, name, and state were always present and string-shaped, then called padEnd() / length on them directly.
  • Missing detection / guardrail: the cron store load path preserves backward compatibility for malformed legacy rows, but the CLI list formatter had regression coverage only for missing sessionTarget, not other malformed display fields.
  • Prior context (git blame, prior PR, issue, or refactor if known): issue #59968 reported the same user-facing symptom, although the exact stale payload shape in the report uses older field naming.
  • Why this regressed now: legacy or hand-edited persisted jobs can still reach the CLI renderer without full shape repair, so the formatter remained a crash point.
  • If unknown, what was ruled out: ruled out the typed cron.list --json response path and the general table renderer; the crash came from the dedicated cron CLI formatter.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/cli/cron-cli/shared.test.ts
  • Scenario the test should lock in: malformed persisted rows with missing display fields like name or id do not crash printCronList().
  • Why this is the smallest reliable guardrail: the bug is isolated to the dedicated cron CLI renderer, so a focused formatter test covers the exact failure mode without expanding cron service scope.
  • Existing test that already covers this (if any): existing coverage already handled missing sessionTarget only.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • openclaw cron list now renders placeholders instead of throwing when loaded cron jobs are missing expected display fields.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS 15.6
  • Runtime/container: local Node/pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): default local repo checkout

Steps

  1. Create or load a persisted cron job with a missing display field such as name or id.
  2. Run the human-readable cron list path.
  3. Confirm the CLI prints the job table instead of throwing.

Expected

  • openclaw cron list stays readable and uses placeholders for malformed fields.

Actual

  • Before the fix, the dedicated formatter could throw from direct padEnd() / length access on malformed stored rows.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: reproduced the formatter crash locally with malformed stored rows, then verified the fixed formatter and new regression tests; also reran the focused cron CLI test files.
  • Edge cases checked: missing sessionTarget, missing name, missing id, and missing state reads in the cron list formatter path.
  • What you did not verify: I did not broaden scope into repairing malformed jobs on disk.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: placeholder rendering could hide malformed stored data from operators.
    • Mitigation: scope is limited to display safety, and malformed rows remain visible instead of crashing the command.

Additional Notes

  • Local verification completed: pnpm build, pnpm check, pnpm test -- src/cli/cron-cli/shared.test.ts src/cli/cron-cli.test.ts.
  • Local pnpm test currently hits an unrelated failure in src/tts/status-config.test.ts (provider: \"auto\" vs \"microsoft\"), outside this PR's diff.

AI Assistance

  • AI-assisted
  • Degree of testing noted above
  • Prompts/session logs attached
  • I reviewed the final code and understand the change

Made with Cursor

Changed files

  • src/cli/cron-cli/shared.test.ts (modified, +29/-0)
  • src/cli/cron-cli/shared.ts (modified, +39/-22)

PR #60057: fix(cron): add null guard for job.name in printCronList

Description (problem / solution / changelog)

Summary

job.name is typed as required in CronJob but can be undefined at runtime (e.g. jobs persisted before the field was introduced). In printCronList, passing undefined to truncate then pad causes .padEnd to throw.

  • Add ?? "-" fallback for job.name, consistent with how job.agentId and job.sessionTarget are already guarded on the same lines below

Test plan

  • Run openclaw cron list against a gateway that has at least one cron job with no name field — should render - instead of crashing
  • Existing cron-cli tests pass

Fixes #59968

🤖 Generated with Claude Code

Changed files

  • src/cli/cron-cli/shared.ts (modified, +1/-1)

Code Example

{
  "jobs": [
    {
      "jobId": "a-stock-close-report",
      "name": "A股收盘报告",
      "enabled": true,
      "description": "每个交易日(周一至周五)15:10自动发送A股收盘报告",
      "schedule": {
        "kind": "cron",
        "expr": "10 15 * * 1-5",
        "tz": "Asia/Shanghai"
      },
      "sessionTarget": "isolated",
      "payload": {
        "kind": "agentTurn",
        "agentId": "zoro",
        "message": "...",
        "timeoutSeconds": 120
      },
      "delivery": {
        "mode": "announce",
        "channel": "feishu"
      },
      "state": {
        "nextRunAtMs": 1775200200000
      }
    }
  ],
  "total": 1
}
RAW_BUFFERClick to expand / collapse

Describe the Bug

Running openclaw cron list throws the following error:

Steps to Reproduce

  1. Run openclaw cron list on the command line

Expected Behavior

A table of cron jobs should be displayed.

Actual Behavior

Throws a TypeError related to padEnd.

Environment

  • OpenClaw version: 2026.4.2 (d74a122)

Workaround

Using openclaw cron list --json works correctly and returns the expected JSON data.

JSON Output (from --json flag)

{
  "jobs": [
    {
      "jobId": "a-stock-close-report",
      "name": "A股收盘报告",
      "enabled": true,
      "description": "每个交易日(周一至周五)15:10自动发送A股收盘报告",
      "schedule": {
        "kind": "cron",
        "expr": "10 15 * * 1-5",
        "tz": "Asia/Shanghai"
      },
      "sessionTarget": "isolated",
      "payload": {
        "kind": "agentTurn",
        "agentId": "zoro",
        "message": "...",
        "timeoutSeconds": 120
      },
      "delivery": {
        "mode": "announce",
        "channel": "feishu"
      },
      "state": {
        "nextRunAtMs": 1775200200000
      }
    }
  ],
  "total": 1
}

The data is valid and only one cron job exists. The bug appears to be in the table formatting code where .padEnd() is called on an undefined value.

extent analysis

TL;DR

The issue can likely be fixed by ensuring that the value passed to padEnd() is not undefined, possibly by adding a null check or default value in the table formatting code.

Guidance

  • Review the table formatting code to identify where padEnd() is being called and verify that the value being passed is defined.
  • Check if there are any recent changes to the code that could be causing the padEnd() method to be called on an undefined value.
  • Consider adding a temporary workaround to handle the case where the value is undefined, such as returning a default value or skipping the formatting for that specific field.
  • Use the --json flag as a temporary workaround to retrieve the cron job data in JSON format, which is not affected by the table formatting issue.

Example

// Example of adding a null check before calling padEnd()
if (value !== undefined) {
  formattedValue = value.padEnd(10);
} else {
  formattedValue = ''; // or some other default value
}

Notes

The exact fix will depend on the specific implementation of the table formatting code, which is not provided in the issue. The example above is a general illustration of how to add a null check before calling padEnd().

Recommendation

Apply workaround: use the --json flag to retrieve the cron job data in JSON format until the underlying issue with the table formatting code is resolved. This is because the JSON output is not affected by the padEnd() issue and can provide a temporary solution for retrieving the cron job data.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING