{"record":{"id":"c222bbd8acac5602","repo":"pocketbase/pocketbase","slug":"invalid-segment-step-step-1-could-be-used-only","errorCode":null,"errorMessage":"invalid segment step - step > 1 could be used only with the wildcard or range format","messagePattern":"invalid segment step - step > 1 could be used only with the wildcard or range format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/cron/schedule.go","lineNumber":177,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"invalid segment step boundary - the step must be between 1 and the %d\", max)\n\t\t\t}\n\t\t\tstep = parsedStep\n\t\tdefault:\n\t\t\treturn nil, errors.New(\"invalid segment step format - must be in the format */n or 1-30/n\")\n\t\t}\n\n\t\t// find the min and max range of the segment part\n\t\tvar rangeMin, rangeMax int\n\t\tif stepParts[0] == \"*\" {\n\t\t\trangeMin = min\n\t\t\trangeMax = max\n\t\t} else {\n\t\t\t// single digit (1) or range (1-30)\n\t\t\trangeParts := strings.Split(stepParts[0], \"-\")\n\t\t\tswitch len(rangeParts) {\n\t\t\tcase 1:\n\t\t\t\tif step != 1 {\n\t\t\t\t\treturn nil, errors.New(\"invalid segment step - step > 1 could be used only with the wildcard or range format\")\n\t\t\t\t}\n\t\t\t\tparsed, err := strconv.Atoi(rangeParts[0])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif parsed < min || parsed > max {\n\t\t\t\t\treturn nil, errors.New(\"invalid segment value - must be between the min and max of the segment\")\n\t\t\t\t}\n\t\t\t\trangeMin = parsed\n\t\t\t\trangeMax = rangeMin\n\t\t\tcase 2:\n\t\t\t\tparsedMin, err := strconv.Atoi(rangeParts[0])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif parsedMin < min || parsedMin > max {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid segment range minimum - must be between %d and %d\", min, max)\n\t\t\t\t}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/pocketbase/pocketbase/blob/5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457/tools/cron/schedule.go#L159-L195","documentation":"Returned by parseCronSegment when a step value greater than 1 is combined with a single bare value instead of a wildcard or range — e.g. the minutes segment \"5/2\". The parser only supports steps on \"*\" (*/2) or on ranges (10-50/2); a step on a single number has no meaning (it fires at most once), so it is rejected.","triggerScenarios":"Writing a segment like \"5/2\", \"12/5\" or \"1/10\" in any of the five fields; porting expressions from systems (e.g. some cloud schedulers) that accept value/step syntax.","commonSituations":"Developer intends 'every 2 starting at 5' and writes 5/2 instead of the range form; converting cron from Kubernetes/AWS EventBridge notation which has slightly different step semantics.","solutions":["Rewrite the single-value step as an explicit range with the desired start: \"5-59/2\" for minutes.","If you meant 'every N', use the wildcard form \"*/2\".","If you meant the single value, drop the step: just \"5\".","Test the expression against NewSchedule in a unit test when it comes from user/config input."],"exampleFix":"# before\n0 5/2 * * *   # step on single value -> error\n\n# after\n0 5-59/2 * * *  # every 2 minutes starting at :05","handlingStrategy":"validation","validationCode":"// reject value/step on a bare number before calling Add\nvar bareStepRe = regexp.MustCompile(`^\\d+/\\d+$`)\nif bareStepRe.MatchString(segment) {\n    return fmt.Errorf(\"%q: use */N or min-max/N instead of value/N\", segment)\n}","typeGuard":null,"tryCatchPattern":"if _, err := cron.NewSchedule(expr); err != nil {\n    return fmt.Errorf(\"schedule %q rejected: %w — rewrite single-value steps as ranges\", expr, err)\n}","preventionTips":["Prefer */N for 'every N' and min-max/N for 'starting at min, every N'.","Do not port step-on-value syntax from other schedulers verbatim.","Keep a lint/test suite over configured cron expressions."],"tags":["cron","expression-parsing","step-syntax","go"],"backgroundTag":null,"analyzedSha":"5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457","analyzedAt":"2026-08-15T10:06:33.165Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}