Skip to content

Commit 12dba6c

Browse files
fix: improve schedule validation
1 parent 396d080 commit 12dba6c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

coderd/schedule/cron/schedule_validation.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ func SchedulesOverlap(schedule1, schedule2 string) (bool, error) {
3131
fields1 := strings.Fields(schedule1)
3232
fields2 := strings.Fields(schedule2)
3333

34+
if len(fields1) != 5 {
35+
return false, xerrors.Errorf("schedule %q has %d fields, expected 5 fields (minute hour day-of-month month day-of-week)", schedule1, len(fields1))
36+
}
37+
if len(fields2) != 5 {
38+
return false, xerrors.Errorf("schedule %q has %d fields, expected 5 fields (minute hour day-of-month month day-of-week)", schedule2, len(fields2))
39+
}
40+
3441
// Check if months overlap
3542
monthsOverlap, err := MonthsOverlap(fields1[3], fields2[3])
3643
if err != nil {

0 commit comments

Comments
 (0)