{"record":{"id":"4b38b699790b605c","repo":"gohugoio/hugo","slug":"increment-must-be-0","errorCode":null,"errorMessage":"'increment' must be > 0","messagePattern":"'increment' must be > 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/collections.go","lineNumber":464,"sourceCode":"\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\n\t}\n\n\tseq := make([]int, size)","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/collections/collections.go#L446-L482","documentation":"Thrown by Seq in the 3-argument form when first < last but the increment is negative (line 463). A negative step cannot reach a larger 'last' from a smaller 'first', so the call is contradictory and rejected. This prevents a silently-empty or infinite result.","triggerScenarios":"Calling {{ seq 1 -1 10 }} (start 1, end 10, but step -1); passing swapped start/end with the wrong sign on step; computed start/end where the order assumption is inverted.","commonSituations":"Swapping start and end without flipping the step sign; reusing a 'decrement' template snippet in an ascending context; off-by confusion about argument order (start, increment, end).","solutions":["Match the step sign to the direction: ascending => positive step ({{ seq 1 1 10 }}).","If you want descending from high to low, call {{ seq 10 -1 1 }} (first > last, negative step).","Double-check argument order: it is start, increment, end."],"exampleFix":"// before\n{{ seq 1 -1 10 }}\n// after\n{{ seq 1 1 10 }}","handlingStrategy":"validation","validationCode":"{{/* ascending: positive step */}}\n{{ seq 1 1 10 }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match step sign to direction: ascending => positive.","Remember argument order: start, increment, end.","When reusing a decrement snippet for ascending, flip the sign."],"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-14T05:17:10.506Z"}