{"record":{"id":"0c6d33857e772f63","repo":"temporalio/temporal","slug":"s-is-not-in-range-d-d","errorCode":null,"errorMessage":"%s is not in range [%d-%d]","messagePattern":"(.+?) is not in range \\[(.+?)-(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/scheduler/calendar.go","lineNumber":468,"sourceCode":"\t\t\t\t// Only a single dash is allowed to denote a range (e.g. \"1-5\").\n\t\t\t\t// Inputs with multiple dashes like \"1-5-7\" should raise the\n\t\t\t\t// canonical \"too many dashes\" error expected by tests.\n\t\t\t\tif strings.Count(part, \"-\") > 1 { // no negative numbers are expected in spec\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s has too many dashes\", field)\n\t\t\t\t}\n\t\t\t\trangeParts := strings.SplitN(part, \"-\", 2)\n\t\t\t\tif len(rangeParts) != 2 {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s has too many dashes\", field)\n\t\t\t\t}\n\t\t\t\tif start, err = parseValue(rangeParts[0], minVal, maxVal, parseMode); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s Start is not in range [%d-%d]\", field, minVal, maxVal)\n\t\t\t\t}\n\t\t\t\tif end, err = parseValue(rangeParts[1], start, maxVal, parseMode); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s End is before Start or not in range [%d-%d]\", field, minVal, maxVal)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif start, err = parseValue(part, minVal, maxVal, parseMode); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%s is not in range [%d-%d]\", field, minVal, maxVal)\n\t\t\t\t}\n\t\t\t\tif !hasStep {\n\t\t\t\t\t// if / is present, a single value is treated as that value to the\n\t\t\t\t\t// end. otherwise a single value is just the single value.\n\t\t\t\t\tend = start\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Special handling for Sunday: Turn \"7\" into \"0\", which may require an extra range.\n\t\t// Consider some cases:\n\t\t// 0-7 or 1-7   can turn into 0-6\n\t\t// 3-7          has to turn into 0,3-6\n\t\t// 3-7/3        can turn into 3-6/3  (7 doesn't match)\n\t\t// 1-7/2        has to turn into 0,1-6/2\n\t\t// That is, we can use a single range and just turn the 7 into a 6 only if step == 1\n\t\t// and start == 0 or 1. Or if 7 isn't actually included. In other cases, we can add a\n\t\t// 0, and then turn the 7 into a 6 in whatever the original range was. If the original\n\t\t// range was just 7-7, then we're done.","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/scheduler/calendar.go#L450-L486","documentation":"makeRange parses a single value (no dash) for a calendar field via parseValue(part, minVal, maxVal, parseMode). Failure produces this error naming the field and bounds. Invalid tokens include out-of-range numbers and, depending on parse mode, unrecognized names like 'MON' or wildcards in a value position.","triggerScenarios":"A Schedule's CalendarSpec/RangesSpec field set to an invalid single value, e.g. Minute: \"61\", DayOfWeek: \"7\" where 0-6 is expected, or an unparseable token.","commonSituations":"Off-by-one mistakes (day-of-month 32, hour 24); mixing cron 0-6 vs 1-7 day-of-week conventions; passing empty strings or '*' where a concrete value is required.","solutions":["Correct the single value to lie within the printed [min-max] range for the field","Check name conventions (use the field's documented naming, e.g. CalendarSpec accepts 'MON')","Use structured schedule.Spec types (ints) instead of strings to get compile/type-time safety"],"exampleFix":"// before\nspec := &schedule.CalendarSpec{Minute: \"61\"}\n// after\nspec := &schedule.CalendarSpec{Minute: \"59\"}","handlingStrategy":"validation","validationCode":"func validCronValue(v string, min, max int) error {\n    n, err := strconv.Atoi(v)\n    if err != nil || n < min || n > max {\n        return fmt.Errorf(\"value %q must be %d-%d\", v, min, max)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer typed schedule types (CalendarSpec with ints or ScheduleSpec SecondCronString only for well-formed cron)","Watch for cron convention differences (0-6 vs 1-7 day-of-week) when porting expressions","Add unit tests covering every field's boundary values"],"tags":["scheduler","cron-parsing","validation","go"],"backgroundTag":"schedule-field-out-of-range","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}