{"record":{"id":"f0c046ce54b605ad","repo":"temporalio/temporal","slug":"s-end-is-before-start-or-not-in-range-d-d","errorCode":null,"errorMessage":"%s End is before Start or not in range [%d-%d]","messagePattern":"(.+?) End is before Start or not in range \\[(.+?)-(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/scheduler/calendar.go","lineNumber":464,"sourceCode":"\n\t\tstart, end := minVal, maxVal\n\t\tif part != \"*\" {\n\t\t\tif strings.Contains(part, \"-\") {\n\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","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/scheduler/calendar.go#L446-L482","documentation":"In makeRange, the end bound of a 'start-end' range expression is parsed with parseValue(rangeParts[1], start, maxVal, ...). If the end value is below start or outside the field's allowed bounds, this error is returned. It conflates two causes: end-before-start and plain out-of-range.","triggerScenarios":"Range expressions like '10-5' (end before start), '0-99' on a minutes field, or an invalid end token in a Scheduler calendar spec field.","commonSituations":"Typos transposing range bounds; assuming wrapping ranges (like '22-2' hours) are supported when they are not; copying ranges across fields with different maxima.","solutions":["Ensure end >= start within the same range part (use multiple ranges or step expressions instead of wrapping)","Verify the end bound is within the field's [min-max] range","Pre-validate schedule strings with the SDK's schedule parser before workflow creation"],"exampleFix":"// before\nHour: \"22-2\" // wrapping not supported\n// after\nHour: \"22-23\" // plus a second spec entry for \"0-2\"","handlingStrategy":"validation","validationCode":"func validCronRangeOrder(part string) error {\n    p := strings.SplitN(part, \"-\", 2)\n    if len(p) != 2 { return nil }\n    s, err1 := strconv.Atoi(strings.TrimSpace(p[0]))\n    e, err2 := strconv.Atoi(strings.TrimSpace(p[1]))\n    if err1 == nil && err2 == nil && e < s {\n        return fmt.Errorf(\"range end %d before start %d (wrapping unsupported)\", e, s)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never write wrapping ranges like '22-2'; split into '22-23' and '0-2' entries","Validate ranges with the SDK parser in CI before creating schedules","Use CalendarSpec structured fields instead of raw strings"],"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"}