Skip to content

Commit bbcc812

Browse files
1052326311steipete
authored andcommitted
fix(doctor): warn and continue when cron job store is unreadable
Catch non-ENOENT load failures inside maybeRepairLegacyCronStore so an unreadable ~/.openclaw/cron/jobs.json (e.g. root-owned 0600 inside Docker) no longer aborts the rest of the doctor health checks. The scheduler-side loadCronStore keeps its strict throw-on-read-failure contract. Closes #86102
1 parent e9b8a6e commit bbcc812

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Docs: https://docs.openclaw.ai
2020
- Cron: accept leading-plus relative durations such as `+5m` for one-shot `--at` schedules. (#86341) Thanks @mushuiyu886.
2121
- Agents/media: preserve async-started media tool metadata so background generation starts no longer surface generic incomplete-turn warnings while replay stays unsafe. (#85933) Thanks @fuller-stack-dev.
2222
- xAI/LM Studio: avoid buffering ordinary bracketed or `final` prose until stream completion while watching for plain-text tool-call fallbacks.
23+
- Doctor: warn and continue when the cron job store exists but cannot be read (e.g. owned by another user with `0600` mode inside Docker) so later health checks still run. (#86102)
2324
- Discord: suppress a bot's previous reply body and referenced media from prompt context when a user replies to that bot message, while keeping reply metadata for routing. (#86238) Thanks @fuller-stack-dev.
2425
- Docker E2E: avoid rebuilding the Control UI twice while preparing the shared OpenClaw package tarball for package-backed scenario runs.
2526
- Tests: avoid rebuilding the Control UI twice during the installer Docker smoke now that `pnpm build` includes `ui:build`.

‎src/commands/doctor-cron.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,29 @@ describe("maybeRepairLegacyCronStore", () => {
566566
expectNoteContaining("managed dreaming job", "Cron");
567567
expectNoteContaining("Rewrote 1 managed dreaming job", "Doctor changes");
568568
});
569+
570+
it("warns and continues when the cron job store cannot be read", async () => {
571+
const storePath = await makeTempStorePath();
572+
// Force loadCronStore to throw a non-ENOENT read error by placing a
573+
// directory where the cron job store file would be. This mirrors the
574+
// Docker-on-root permission failure reported in #86102 without depending
575+
// on the test runner's effective uid (root bypasses chmod gates).
576+
await fs.mkdir(path.dirname(storePath), { recursive: true });
577+
await fs.mkdir(storePath);
578+
const prompter = makePrompter(true);
579+
580+
await expect(
581+
maybeRepairLegacyCronStore({
582+
cfg: { cron: { store: storePath } },
583+
options: {},
584+
prompter,
585+
}),
586+
).resolves.toBeUndefined();
587+
588+
expect(prompter.confirm).not.toHaveBeenCalled();
589+
expectNoteContaining("Unable to read cron job store at", "Cron");
590+
expectNoteContaining("later health checks will continue", "Cron");
591+
});
569592
});
570593

571594
describe("legacy WhatsApp crontab health check", () => {

‎src/commands/doctor-cron.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,21 @@ export async function maybeRepairLegacyCronStore(params: {
335335
prompter: Pick<DoctorPrompter, "confirm">;
336336
}) {
337337
const storePath = resolveCronStorePath(params.cfg.cron?.store);
338-
const store = await loadCronStore(storePath);
338+
let store: Awaited<ReturnType<typeof loadCronStore>>;
339+
try {
340+
store = await loadCronStore(storePath);
341+
} catch (err) {
342+
const reason = err instanceof Error ? err.message : String(err);
343+
note(
344+
[
345+
`Unable to read cron job store at ${shortenHomePath(storePath)}.`,
346+
`- ${reason}`,
347+
`Fix the file's permissions or contents and re-run ${formatCliCommand("openclaw doctor")}; later health checks will continue.`,
348+
].join("\n"),
349+
"Cron",
350+
);
351+
return;
352+
}
339353
const rawJobs = (store.jobs ?? []) as unknown as Array<Record<string, unknown>>;
340354
if (rawJobs.length === 0) {
341355
return;

0 commit comments

Comments
 (0)