openclaw - ✅(Solved) Fix `openclaw doctor` crashes on Termux/partial Linux environments instead of degrading gracefully [1 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#77773Fetched 2026-05-06 06:21:42
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
commented ×1cross-referenced ×1

On OpenClaw 2026.5.4, openclaw doctor crashes with:

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

This was reproduced on Termux on Android. I realize that may be outside the primary support matrix, but even in unsupported environments doctor should ideally warn/skip and continue rather than crash.

Error Message

The crash was traced to the legacy-cron doctor contribution:

TypeError: Cannot read properties of undefined (reading 'split')
    at findLegacyWhatsAppHealthCrontabLines (.../dist/doctor-cron-*.js)
    at noteLegacyWhatsAppCrontabHealthCheck (.../dist/doctor-cron-*.js)
    at async Object.runLegacyCronHealth [as run] (.../dist/doctor-health-contributions-*.js)

The relevant code path appears to assume crontab is always a string and does:

return crontab.split(/\r?\n/u)...

In this environment, the value flowing into that function was undefined.

Root Cause

Even if Termux is unsupported, this looks like a general robustness issue:

  • a doctor sub-check should not be able to abort the entire doctor run because an external command or environment-specific probe returned an unexpected shape
  • the command should degrade gracefully and keep reporting the rest of the health information

Fix Action

Fixed

PR fix notes

PR #78112: [AI-assisted] fix(doctor): tolerate malformed crontab output

Description (problem / solution / changelog)

Summary

  • Fixes #77773.
  • Harden the legacy WhatsApp crontab doctor contribution so malformed, nullish, or non-string crontab output does not abort openclaw doctor.
  • Harden terminal note wrapping so unexpected nullish/non-string note messages are coerced before wrapping.
  • Add focused regression coverage for malformed crontab output and note message coercion.

Real behavior proof

Behavior or issue addressed: openclaw doctor could crash on partial Linux/Termux-style environments when the legacy cron probe received stdout: undefined and called .split(...). The terminal note wrapper had the same unsafe string assumption for unexpected note messages.

Real environment tested: Local OpenClaw source checkout on branch fix-doctor-cron-termux-77773, commit d7958fbb30, using corepack pnpm and Node from the workspace on Windows/PowerShell.

Exact steps or command run after this patch: Ran a PowerShell here-string containing the TSX snippet below and piped it to corepack pnpm exec tsx - from the patched checkout.

import { noteLegacyWhatsAppCrontabHealthCheck } from "./src/commands/doctor-cron.ts";
import { wrapNoteMessage } from "./src/terminal/note.ts";

const observed = [];
await noteLegacyWhatsAppCrontabHealthCheck({
  platform: "linux",
  readCrontab: async () => ({ stdout: undefined }),
});
observed.push({ case: "undefined crontab stdout", result: "completed without throwing" });
await noteLegacyWhatsAppCrontabHealthCheck({
  platform: "linux",
  readCrontab: async () => ({ stdout: 12345 }),
});
observed.push({ case: "numeric crontab stdout", result: "completed without throwing" });
observed.push({ case: "undefined note message", result: JSON.stringify(wrapNoteMessage(undefined, { maxWidth: 20, columns: 80 })) });
observed.push({ case: "numeric note message", result: wrapNoteMessage(12345, { maxWidth: 20, columns: 80 }) });
console.log(JSON.stringify(observed, null, 2));

Evidence after fix: Copied terminal output from the command above:

[
  {
    "case": "undefined crontab stdout",
    "result": "completed without throwing"
  },
  {
    "case": "numeric crontab stdout",
    "result": "completed without throwing"
  },
  {
    "case": "undefined note message",
    "result": "\"\""
  },
  {
    "case": "numeric note message",
    "result": "12345"
  }
]

Observed result after fix: The legacy cron doctor contribution completed without throwing for stdout: undefined and numeric stdout, and note wrapping returned safe text for nullish/non-string messages.

What was not tested: I did not run on live Termux/Android hardware. The proof exercises the failing OpenClaw doctor contribution boundary and note wrapper in the source checkout with the same malformed values described in the issue.

Verification

  • corepack pnpm exec oxfmt --check --threads=1 src/commands/doctor-cron.ts src/commands/doctor-cron.test.ts src/terminal/note.ts src/terminal/table.test.ts CHANGELOG.md
  • corepack pnpm exec oxlint src/commands/doctor-cron.ts src/commands/doctor-cron.test.ts src/terminal/note.ts src/terminal/table.test.ts
  • corepack pnpm check:changelog-attributions
  • git diff --check origin/main...HEAD
  • $env:WT_SESSION='1'; corepack pnpm test src/commands/doctor-cron.test.ts src/terminal/table.test.ts
  • corepack pnpm exec tsgo -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
  • corepack pnpm exec tsgo -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
  • corepack pnpm check:changed

AI-assisted

This PR was prepared with Codex assistance. I reviewed the issue, ClawSweeper guidance, changed code, and local verification before opening it.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/commands/doctor-cron.test.ts (modified, +29/-0)
  • src/commands/doctor-cron.ts (modified, +17/-4)
  • src/terminal/note.ts (modified, +20/-3)
  • src/terminal/table.test.ts (modified, +8/-0)

Code Example

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

---

openclaw doctor

---

TypeError: Cannot read properties of undefined (reading 'split')
    at findLegacyWhatsAppHealthCrontabLines (.../dist/doctor-cron-*.js)
    at noteLegacyWhatsAppCrontabHealthCheck (.../dist/doctor-cron-*.js)
    at async Object.runLegacyCronHealth [as run] (.../dist/doctor-health-contributions-*.js)

---

return crontab.split(/\r?\n/u)...

---

return message.split("\n")...

---

const text = typeof crontab === "string" ? crontab : crontab == null ? "" : String(crontab);
return text.split(/\r?\n/u)...

---

message = typeof message === "string" ? message : message == null ? "" : String(message);
return message.split("\n")...
RAW_BUFFERClick to expand / collapse

Summary

On OpenClaw 2026.5.4, openclaw doctor crashes with:

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

This was reproduced on Termux on Android. I realize that may be outside the primary support matrix, but even in unsupported environments doctor should ideally warn/skip and continue rather than crash.

Reproduction

Environment:

  • OpenClaw 2026.5.4
  • Termux on Android

Command:

openclaw doctor

Observed result:

  • doctor runs partway through
  • then exits with TypeError: Cannot read properties of undefined (reading 'split')

Stack trace

The crash was traced to the legacy-cron doctor contribution:

TypeError: Cannot read properties of undefined (reading 'split')
    at findLegacyWhatsAppHealthCrontabLines (.../dist/doctor-cron-*.js)
    at noteLegacyWhatsAppCrontabHealthCheck (.../dist/doctor-cron-*.js)
    at async Object.runLegacyCronHealth [as run] (.../dist/doctor-health-contributions-*.js)

The relevant code path appears to assume crontab is always a string and does:

return crontab.split(/\r?\n/u)...

In this environment, the value flowing into that function was undefined.

Additional robustness issue

There also appears to be a similar defensive gap in the note wrapper:

return message.split("\n")...

If any doctor/note caller passes undefined, doctor can also crash there instead of rendering a warning.

Expected behavior

Even on unsupported or partially supported environments:

  • openclaw doctor should not crash
  • environment-specific checks should be skipped or downgraded to warnings when prerequisites are unavailable

Minimal fix idea

Two defensive guards were enough locally:

  1. In doctor-cron:
const text = typeof crontab === "string" ? crontab : crontab == null ? "" : String(crontab);
return text.split(/\r?\n/u)...
  1. In the note wrapper:
message = typeof message === "string" ? message : message == null ? "" : String(message);
return message.split("\n")...

Why this seems worth fixing upstream

Even if Termux is unsupported, this looks like a general robustness issue:

  • a doctor sub-check should not be able to abort the entire doctor run because an external command or environment-specific probe returned an unexpected shape
  • the command should degrade gracefully and keep reporting the rest of the health information

extent analysis

TL;DR

Add defensive checks to handle undefined or non-string values in crontab and message variables to prevent crashes.

Guidance

  • Verify that the crontab and message variables are properly checked for undefined or non-string values before attempting to call split() on them.
  • Apply the suggested minimal fix idea by adding type checks and default values for crontab and message variables.
  • Consider adding additional logging or warnings to handle cases where environment-specific checks are skipped or downgraded.
  • Review the code for similar defensive gaps in other areas where external commands or environment-specific probes are used.

Example

const text = typeof crontab === "string" ? crontab : crontab == null ? "" : String(crontab);
return text.split(/\r?\n/u)...

message = typeof message === "string" ? message : message == null ? "" : String(message);
return message.split("\n")...

Notes

The provided fix idea seems to address the immediate issue, but it's essential to review the codebase for similar vulnerabilities to ensure the doctor command is robust across different environments.

Recommendation

Apply the workaround by adding defensive checks for undefined or non-string values in crontab and message variables, as this will prevent crashes and allow the doctor command to degrade gracefully in unsupported environments.

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

Even on unsupported or partially supported environments:

  • openclaw doctor should not crash
  • environment-specific checks should be skipped or downgraded to warnings when prerequisites are unavailable

Still need to ship something?

×6

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

Back to top recommendations

TRENDING