{"record":{"id":"fb7df680a7499257","repo":"gohugoio/hugo","slug":"increment-must-not-be-0","errorCode":null,"errorMessage":"'increment' must not be 0","messagePattern":"'increment' must not be 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/collections.go","lineNumber":461,"sourceCode":"\t\tlast = first\n\t\tif last == 0 {\n\t\t\treturn []int{}, nil\n\t\t} else if last > 0 {\n\t\t\tfirst = 1\n\t\t} else {\n\t\t\tfirst = -1\n\t\t\tinc = -1\n\t\t}\n\t} else if len(intArgs) == 2 {\n\t\tlast = intArgs[1]\n\t\tif last < first {\n\t\t\tinc = -1\n\t\t}\n\t} else {\n\t\tinc = intArgs[1]\n\t\tlast = intArgs[2]\n\t\tif inc == 0 {\n\t\t\treturn nil, errors.New(\"'increment' must not be 0\")\n\t\t}\n\t\tif first < last && inc < 0 {\n\t\t\treturn nil, errors.New(\"'increment' must be > 0\")\n\t\t}\n\t\tif first > last && inc > 0 {\n\t\t\treturn nil, errors.New(\"'increment' must be < 0\")\n\t\t}\n\t}\n\n\t// sanity check\n\tif last < -maxSeqSize {\n\t\treturn nil, errSeqSizeExceedsLimit\n\t}\n\tsize := ((last - first) / inc) + 1\n\n\t// sanity check\n\tif size <= 0 || size > maxSeqSize {\n\t\treturn nil, errSeqSizeExceedsLimit","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/collections/collections.go#L443-L479","documentation":"Thrown by Seq in the 3-argument form when the increment (second argument) is exactly 0 (line 460). A zero step would loop infinitely (val += 0 never progresses), so it is rejected before the size is computed.","triggerScenarios":"Calling {{ seq 1 0 10 }} explicitly; passing a computed increment that resolves to 0 such as {{ seq 1 (sub $a $a) 10 }}; a front matter 'step' param set to 0.","commonSituations":"Dynamic step math collapsing to zero; user-configurable step params not bounded away from zero; defaulting a step variable to 0 by mistake.","solutions":["Use a non-zero increment: {{ seq 1 1 10 }} for step 1, {{ seq 10 -1 1 }} for step -1.","Clamp the computed step away from zero: {{ $step := cond (eq $step 0) 1 $step }} {{ seq 1 $step 10 }}.","Validate user-provided step params to reject 0 at the content/config level."],"exampleFix":"// before\n{{ seq 1 0 10 }}\n// after\n{{ seq 1 1 10 }}","handlingStrategy":"validation","validationCode":"{{ $step := cond (eq $step 0) 1 $step }}\n{{ seq 1 $step 10 }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass 0 as the increment in the 3-arg form.","Clamp computed steps away from zero.","Reject step=0 in user-configurable params."],"tags":["hugo","template","collections","seq","validation","arithmetic"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}