{"record":{"id":"fa65b06be65e26e9","repo":"Netflix/chaosmonkey","slug":"d-is-not-in-cron-range-0-23","errorCode":null,"errorMessage":"%d is not in cron range(0-23)","messagePattern":"(.+?) is not in cron range\\(0-23\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/monkey.go","lineNumber":475,"sourceCode":"\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn fmt.Sprintf(defaultCron, runAtHour), nil\n\t}\n\tswitch cron := cron.(type) {\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"%s: unexpected type %T\", param.CronExpression, cron)\n\tcase string:\n\t\treturn cron, nil\n\t}\n}\n\n// calculates the default cron run hour based on startHour.\n// The default cron starts \"cronBeforeStartHour\" hours\n// before \"startHour\"\nfunc calculateDefaultCronRunHour(startHour int) (int, error) {\n\tif (startHour < clockStartHour) || (startHour > clockEndHour) {\n\t\treturn -1, errors.Errorf(\"%d is not in cron range(0-23)\", startHour)\n\t}\n\trunAtHour := startHour - cronBeforeStartHour\n\tif runAtHour < 0 {\n\t\t// assuming a 24 hour clock system(0 - 23), -ve values means going back to previous day\n\t\t// e.g. if start hour is 0 (midnight), the \"cronTime\" time should be 22 hours\n\t\t// on the previous day.\n\t\treturn hoursInClock + runAtHour, nil\n\t}\n\treturn runAtHour, nil\n}\n\n// ScheduleCronPath returns the path to which\n// main chaosmonkey crontab is located\nfunc (m *Monkey) ScheduleCronPath() string {\n\treturn m.v.GetString(param.ScheduleCronPath)\n}\n\n// SchedulePath returns the path to which main","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/config/monkey.go#L457-L493","documentation":"Sentinel-style validation error from the helper calculateDefaultCronRunHour, which computes the default cron hour as startHour minus cronBeforeStartHour. It fires when the caller (CronExpression) passes a startHour outside the allowed clock bounds (below clockStartHour or above clockEndHour, nominally 0-23); the faulty input is the out-of-range startHour integer.","triggerScenarios":"CronExpression() is called with a configured start hour below clockStartHour (0) or above clockEndHour (23), e.g. startHour = 24 or a negative value.","commonSituations":"Config typo like startHour=2400 or 25, off-by-one from 1-12 or 1-24 style conventions, bad values from an upstream config generator.","solutions":["Set the start hour to a valid 0-23 (24-hour clock) value in config","Validate startHour at config load time before calling CronExpression","Check for clock conventions mixing 1-24 or 12-hour formats"],"exampleFix":"// before\nstartHour = 25\n// after\nstartHour = 1","handlingStrategy":"validation","validationCode":"func validHour(h int) bool { return h >= 0 && h <= 23 }\nif !validHour(cfg.StartHour()) {\n    return fmt.Errorf(\"startHour %d must be 0-23\", cfg.StartHour())\n}","typeGuard":null,"tryCatchPattern":"_, err := calculateDefaultCronRunHour(startHour)\nif err != nil {\n    log.Printf(\"invalid start hour %d, defaulting to 0\", startHour)\n    startHour = 0\n}","preventionTips":["Validate startHour at config load time","Use the 24-hour clock convention (0-23) in docs and schema","Add range assertions in config tests","Reject out-of-range hours before scheduling"],"tags":["config","validation","cron","range-check"],"backgroundTag":"value-out-of-range","analyzedSha":"eaa28fb761c0ebe8644d1333e5d164e9cc3071e9","analyzedAt":"2026-09-03T17:04:39.020Z","contentChangedAt":"2026-09-03T17:04:39.020Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}