Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(automation): accept single-start stepped cron fields in the schedule validator (#17274)

Harsh Kashyap45e4e91ed377
diff --git a/__tests__/utils/automation-schedule.test.ts b/__tests__/utils/automation-schedule.test.ts
index 3b8bcc22dc..b2a4084959 100644
--- a/__tests__/utils/automation-schedule.test.ts
+++ b/__tests__/utils/automation-schedule.test.ts
@@ -153,6 +153,18 @@ describe("automation-schedule", () => {
});
});
+ it("accepts single-start stepped fields, matching croniter's n/m expansion", () => {
+ // Arrange β€” croniter expands `2/2` in the month field to 2,4,6,8,10,12,
+ // so the 31st fires in August/October/December: reachable.
+ const stepped = "0 0 31 2/2 *";
+
+ // Act
+ const result = validateCronSchedule(stepped);
+
+ // Assert
+ expect(result).toEqual({ schedule: stepped });
+ });
+
describe("parseTimeOfDay", () => {
it("parses HH:MM and rejects out-of-range or malformed values", () => {
// Act
diff --git a/src/utils/automation-schedule.ts b/src/utils/automation-schedule.ts
index 4e0d12e1fe..8186a663cd 100644
--- a/src/utils/automation-schedule.ts
+++ b/src/utils/automation-schedule.ts
@@ -199,7 +199,13 @@ function parseCronField(
const start = parseSingleInt(startPart, min, max);
if (start === null) return { kind: "invalid" };
if (endPart === undefined) {
- values.add(start);
+ if (stepPart === undefined) {
+ values.add(start);
+ continue;
+ }
+ // croniter reads `n/m` as `n-max/m`: step from the start value up to the
+ // field maximum, not a single hit at the start.
+ for (let value = start; value <= max; value += step) values.add(value);
continue;
}
const end = parseSingleInt(endPart, min, max);