{"record":{"id":"7d887615ac8651d8","repo":"robfig/cron","slug":"too-many-hyphens-s","errorCode":null,"errorMessage":"too many hyphens: %s","messagePattern":"too many hyphens: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"parser.go","lineNumber":280,"sourceCode":"\tif lowAndHigh[0] == \"*\" || lowAndHigh[0] == \"?\" {\n\t\tstart = r.min\n\t\tend = r.max\n\t\textra = starBit\n\t} else {\n\t\tstart, err = parseIntOrName(lowAndHigh[0], r.names)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tswitch len(lowAndHigh) {\n\t\tcase 1:\n\t\t\tend = start\n\t\tcase 2:\n\t\t\tend, err = parseIntOrName(lowAndHigh[1], r.names)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\tdefault:\n\t\t\treturn 0, fmt.Errorf(\"too many hyphens: %s\", expr)\n\t\t}\n\t}\n\n\tswitch len(rangeAndStep) {\n\tcase 1:\n\t\tstep = 1\n\tcase 2:\n\t\tstep, err = mustParseInt(rangeAndStep[1])\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\n\t\t// Special handling: \"N/step\" means \"N-max/step\".\n\t\tif singleDigit {\n\t\t\tend = r.max\n\t\t}\n\t\tif step > 1 {\n\t\t\textra = 0","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/robfig/cron/blob/bc59245fe10efaed9d51b56900192527ed733435/parser.go#L262-L298","documentation":"getRange splits an expression on '-' to extract a range's low and high bounds. An expression with more than one hyphen has no valid two-endpoint interpretation, so it is rejected with this error naming the offending expression.","triggerScenarios":"Specs like \"1-2-3\" in any field, or negative-looking tokens such as \"*-*-5\" produced by templating mistakes; also a range glued to another hyphenated token.","commonSituations":"Typo while editing cron fields; template substitution injecting extra hyphens; misunderstanding syntax and trying to express a list with hyphens (should use commas).","solutions":["Use at most one hyphen per field component (low-high)","Express multiple values with commas instead: 1,2,3 not 1-2-3","Validate each field with a regex like ^\\d+-\\d+$ before parsing"],"exampleFix":"// before\nsched, err := p.Parse(\"0 0 1-2-3 * *\")\n// after\nsched, err := p.Parse(\"0 0 1-3 * *\")  // range\n// or\nsched, err := p.Parse(\"0 0 1,2,3 * *\") // list","handlingStrategy":"validation","validationCode":"var hyphenRe = regexp.MustCompile(`^[^-]+-[^-]+$`)\nfunc fieldHasSingleHyphen(f string) bool {\n\treturn !strings.Contains(f[:strings.Index(f, \"-\")+1]+strings.TrimPrefix(f, f[:strings.Index(f, \"-\")+1]), \"-\") || hyphenRe.MatchString(f)\n}","typeGuard":null,"tryCatchPattern":"sched, err := parser.Parse(spec)\nif err != nil {\n\treturn fmt.Errorf(\"malformed range in cron spec %q: %w\", spec, err)\n}","preventionTips":["Use one hyphen per range, commas for lists","Lint cron fields with a regex before parsing","Sanitize template-substituted values to avoid stray hyphens"],"tags":["go","cron","parser","syntax","range"],"backgroundTag":"invalid-argument-format","analyzedSha":"bc59245fe10efaed9d51b56900192527ed733435","analyzedAt":"2026-09-07T00:35:06.760Z","contentChangedAt":"2026-09-07T00:35:06.760Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}