fix(cron): guard flat atMs canonicalization · openclaw/openclaw@972d2b6
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -92,6 +92,24 @@ describe("cron tool flat-params", () => {
|
92 | 92 | }); |
93 | 93 | }); |
94 | 94 | |
| 95 | +it("leaves out-of-range flat atMs for gateway validation", async () => { |
| 96 | +const tool = createCronTool(undefined, { callGatewayTool: callGatewayToolMock }); |
| 97 | +const invalidAtMs = 8_640_000_000_000_001; |
| 98 | + |
| 99 | +await tool.execute("call-flat-invalid-atms-add", { |
| 100 | +action: "add", |
| 101 | +name: "bad date", |
| 102 | +atMs: invalidAtMs, |
| 103 | +message: "send reminder", |
| 104 | +}); |
| 105 | + |
| 106 | +const [method, _gatewayOpts, params] = firstGatewayToolCall<{ |
| 107 | +schedule?: { at?: unknown; kind?: unknown }; |
| 108 | +}>(); |
| 109 | +expect(method).toBe("cron.add"); |
| 110 | +expect(params.schedule).toEqual({ kind: "at", at: invalidAtMs }); |
| 111 | +}); |
| 112 | + |
95 | 113 | it("recovers flat cron schedule shorthand for update", async () => { |
96 | 114 | const tool = createCronTool(undefined, { callGatewayTool: callGatewayToolMock }); |
97 | 115 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { timestampMsToIsoString } from "@openclaw/normalization-core/number-coercion"; |
1 | 2 | import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce"; |
2 | 3 | import { Type, type TSchema } from "typebox"; |
3 | 4 | import { getRuntimeConfig } from "../../config/config.js"; |
@@ -132,7 +133,7 @@ function moveDefinedField(params: {
|
132 | 133 | |
133 | 134 | function setScheduleAtMs(schedule: Record<string, unknown>, value: unknown): void { |
134 | 135 | const atMs = typeof value === "number" ? value : Number(value); |
135 | | -schedule.at = Number.isFinite(atMs) ? new Date(Math.floor(atMs)).toISOString() : value; |
| 136 | +schedule.at = Number.isFinite(atMs) ? (timestampMsToIsoString(Math.floor(atMs)) ?? value) : value; |
136 | 137 | } |
137 | 138 | |
138 | 139 | function canonicalizeCronToolSchedule(value: Record<string, unknown>): void { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。