{"id":"fe83b5aded1ff4c7","repo":"gohugoio/hugo","slug":"invalid-number-of-arguments-to-seq","errorCode":null,"errorMessage":"invalid number of arguments to Seq","messagePattern":"invalid number of arguments to Seq","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/collections.go","lineNumber":430,"sourceCode":"}\n\n// Sanity check for slices created by Seq and D.\nconst maxSeqSize = 1000000\n\nvar errSeqSizeExceedsLimit = errors.New(\"size of result exceeds limit\")\n\n// Seq creates a sequence of integers from args. It's named and used as GNU's seq.\n//\n// Examples:\n//\n//\t3 => 1, 2, 3\n//\t1 2 4 => 1, 3\n//\t-3 => -1, -2, -3\n//\t1 4 => 1, 2, 3, 4\n//\t1 -2 => 1, 0, -1, -2\nfunc (ns *Namespace) Seq(args ...any) ([]int, error) {\n\tif len(args) < 1 || len(args) > 3 {\n\t\treturn nil, errors.New(\"invalid number of arguments to Seq\")\n\t}\n\n\tintArgs := cast.ToIntSlice(args)\n\tif len(intArgs) < 1 || len(intArgs) > 3 {\n\t\treturn nil, errors.New(\"invalid arguments to Seq\")\n\t}\n\n\tinc := 1\n\tvar last int\n\tfirst := intArgs[0]\n\n\tif len(intArgs) == 1 {\n\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 {","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/collections/collections.go#L412-L448","documentation":"The `seq` template function mimics GNU seq and accepts 1–3 arguments: LAST, FIRST LAST, or FIRST INCREMENT LAST. Calling it with zero arguments or more than three fails this arity check before any parsing happens.","triggerScenarios":"`{{ seq }}` with no arguments, or `{{ seq 1 2 3 4 }}` with four or more; also passing a slice that spreads into too many args.","commonSituations":"Forgetting to pass the count variable (empty/undefined param evaluated away); confusing `seq`'s signature with `range` over a collection; extra whitespace-split arguments in a partial call.","solutions":["Call with 1–3 integer arguments: `{{ seq 5 }}`, `{{ seq 1 5 }}`, or `{{ seq 1 2 9 }}`.","If the argument comes from a param, guard against it being missing: `{{ with .Params.count }}{{ seq . }}{{ end }}`."],"exampleFix":"<!-- before -->\n{{ range seq }}...{{ end }}\n<!-- after -->\n{{ range seq 1 .Params.count }}...{{ end }}","handlingStrategy":"validation","validationCode":"{{/* seq takes 1..3 args: seq LAST | seq FIRST LAST | seq FIRST INCREMENT LAST */}}\n{{ $args := slice $first $step $last }}\n{{ if or (lt (len $args) 1) (gt (len $args) 3) }}{{ errorf \"seq needs 1-3 args\" }}{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call seq with exactly 1, 2, or 3 arguments.","When building args dynamically (e.g. from params), validate presence of each before splatting.","Prefer the simplest form (`seq $n`) when you just need 1..n."],"tags":["hugo","templates","seq","arguments"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}