Skip to content

Commit 2f9cb92

Browse files
authored
fix(tasks): show registry restore errors in console (#103976)
1 parent 9bfecf4 commit 2f9cb92

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Docs: https://docs.openclaw.ai
185185
- **iOS Gateway auth retry:** restrict stored device-token retry to parsed loopback hosts and reject wildcard bind addresses, preventing remote lookalike hostnames from receiving trusted retry credentials. (#99859) Thanks @ly85206559.
186186
- **Bedrock Mantle discovery:** bound model-catalog fetch time and response size, and release rejected response bodies so stalled, oversized, or failed provider responses fall back safely. (#99961) Thanks @zhangguiping-xydt.
187187
- **Discord thread-title prompts:** truncate generated-title message and channel context on UTF-16 boundaries so emoji cannot leave malformed model prompt text. (#101551) Thanks @Alix-007.
188-
- **Task state migration:** canonicalize legacy `not-requested` delivery statuses during sidecar import and existing shared-database open so upgraded task registries and linked TaskFlows recover without manual SQL. (#103946) Thanks @bek91.
188+
- **Task state migration:** canonicalize legacy `not-requested` delivery statuses during sidecar import and existing shared-database open so upgraded task registries and linked TaskFlows recover without manual SQL, and surface rejected persisted values in compact console diagnostics. (#103946) Thanks @bek91.
189189

190190
## 2026.7.1
191191

‎src/tasks/task-registry.store.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
executeSqliteQueryTakeFirstSync,
88
getNodeSqliteKysely,
99
} from "../infra/kysely-sync.js";
10+
import { resetLogger, setLoggerOverride } from "../logging/logger.js";
11+
import { loggingState } from "../logging/state.js";
1012
import { createWarnLogCapture } from "../logging/test-helpers/warn-log-capture.js";
1113
import type { DB as OpenClawStateKyselyDatabase } from "../state/openclaw-state-db.generated.js";
1214
import {
@@ -113,6 +115,9 @@ describe("task-registry store runtime", () => {
113115
ORIGINAL_ENV.restore();
114116
resetTaskRegistryForTests();
115117
resetTaskFlowRegistryForTests({ persist: false });
118+
loggingState.rawConsole = null;
119+
setLoggerOverride(null);
120+
resetLogger();
116121
});
117122

118123
it("uses the configured task store for restore and save", () => {
@@ -177,6 +182,34 @@ describe("task-registry store runtime", () => {
177182
}
178183
});
179184

185+
it("includes restore parser failures in compact console warnings", () => {
186+
const warn = vi.fn();
187+
const invalidValue = "future-invalid-status";
188+
setLoggerOverride({ level: "silent", consoleLevel: "warn", consoleStyle: "compact" });
189+
loggingState.rawConsole = {
190+
log: vi.fn(),
191+
info: vi.fn(),
192+
warn,
193+
error: vi.fn(),
194+
};
195+
configureTaskRegistryRuntime({
196+
store: {
197+
loadSnapshot: () => {
198+
throw new Error(
199+
`Invalid persisted task delivery status: ${JSON.stringify(invalidValue)}`,
200+
);
201+
},
202+
saveSnapshot: () => {},
203+
},
204+
});
205+
206+
expect(findTaskByRunId("run-restored")).toBeUndefined();
207+
expect(warn).toHaveBeenCalledTimes(1);
208+
expect(String(warn.mock.calls[0]?.[0])).toContain(
209+
`Failed to restore task registry: Invalid persisted task delivery status: "${invalidValue}"`,
210+
);
211+
});
212+
180213
it("uses scoped owner lookups for fresh owner task reads", () => {
181214
const storedTask = createStoredTask();
182215
const loadSnapshot = vi.fn(() => ({

‎src/tasks/task-registry.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,12 @@ function restoreTaskRegistryOnce() {
12321232
tasks: snapshotTaskRecords(tasks),
12331233
}));
12341234
} catch (error) {
1235-
log.warn("Failed to restore task registry", { error: formatErrorMessage(error) });
1235+
const message = formatErrorMessage(error);
1236+
// Compact console logs omit structured metadata, so keep the rejected value visible there too.
1237+
log.warn("Failed to restore task registry", {
1238+
error: message,
1239+
consoleMessage: `Failed to restore task registry: ${message}`,
1240+
});
12361241
}
12371242
}
12381243

0 commit comments

Comments
 (0)