fix(contracts): reject invalid legacy intervals
Keep positive sub-minute schedules readable without accepting corrupt zero or negative persisted intervals. Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
221d15181b
commit
6d07a156d8
2 files changed
+10
-4
No files matched your search
@@ -22,6 +22,10 @@ describe("ScheduledTaskSchedule", () => {
|
||||
everyMs: MIN_SCHEDULED_TASK_INTERVAL_MS - 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("still rejects corrupt non-positive persisted intervals", () => {
|
||||
expect(() => decodeSchedule({ type: "interval", everyMs: 0 })).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ScheduledTaskUpsertSchedule", () => {
|
||||
|
||||
@@ -23,13 +23,15 @@ const TimeOfDay = TrimmedNonEmptyString.check(
|
||||
|
||||
export const MIN_SCHEDULED_TASK_INTERVAL_MS = 60_000;
|
||||
|
||||
const ScheduledTaskIntervalMs = Schema.Int.check(Schema.isGreaterThan(0)).annotate({
|
||||
description: "Positive interval in milliseconds.",
|
||||
});
|
||||
|
||||
const ScheduledTaskIntervalSchedule = Schema.Struct({
|
||||
type: Schema.Literal("interval").annotate({
|
||||
description: "Select interval scheduling.",
|
||||
}),
|
||||
everyMs: Schema.Int.annotate({
|
||||
description: "Interval in milliseconds.",
|
||||
}),
|
||||
everyMs: ScheduledTaskIntervalMs,
|
||||
}).annotate({
|
||||
description: "Run repeatedly after a fixed number of milliseconds.",
|
||||
});
|
||||
@@ -71,7 +73,7 @@ export const ScheduledTaskUpsertSchedule = Schema.Union([
|
||||
type: Schema.Literal("interval").annotate({
|
||||
description: "Select interval scheduling.",
|
||||
}),
|
||||
everyMs: Schema.Int.check(
|
||||
everyMs: ScheduledTaskIntervalMs.check(
|
||||
Schema.isGreaterThanOrEqualTo(MIN_SCHEDULED_TASK_INTERVAL_MS),
|
||||
).annotate({
|
||||
description: "Interval in milliseconds, with a minimum of 60000 (one minute).",
|
||||
|
||||
Reference in new issue
Block a user