{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/collections/collections.go#L412-L448","documentation":"Thrown by Seq when the variadic argument count is not between 1 and 3 inclusive (line 429). Seq accepts exactly 1 (end), 2 (start end), or 3 (start increment end) integer arguments; zero or 4+ is rejected before any value is inspected.","triggerScenarios":"Calling {{ seq }} with no args; {{ seq 1 2 3 4 }} with four args; passing a slice that expands to the wrong arity in a Go caller (ns.Seq(manyArgs...)).","commonSituations":"Template authoring mistake omitting or adding an argument; copy-paste from a 3-arg example into a context needing 1; dynamic arg construction producing the wrong count.","solutions":["Use the correct arity: {{ seq N }} (1..N), {{ seq A B }} (A..B), or {{ seq A I B }} (A, A+I, ... B).","Count your arguments in the template expression and remove extras or add the missing one.","In Go callers, ensure the slice passed to Seq has 1-3 elements."],"exampleFix":"// before\n{{ seq 1 2 3 4 }}\n// after\n{{ seq 1 2 3 }}","handlingStrategy":"validation","validationCode":"// Ensure 1-3 integer args:\n{{ seq 5 }}        {{/* 1 arg: 1..5 */}}\n{{ seq 2 6 }}      {{/* 2 args: 2..6 */}}\n{{ seq 1 2 9 }}    {{/* 3 args: 1,3,5,7,9 */}}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize seq's arity: 1 (end), 2 (start end), 3 (start inc end).","Count arguments in the template expression before rendering.","In Go callers, validate the args slice length is 1-3 before calling Seq."],"tags":["hugo","template","collections","seq","arity","argument-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}