{"record":{"id":"3ee03c90b70839bc","repo":"gohugoio/hugo","slug":"invalid-arguments-to-seq","errorCode":null,"errorMessage":"invalid arguments to Seq","messagePattern":"invalid arguments to Seq","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/collections.go","lineNumber":435,"sourceCode":"var 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 {\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]","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/collections/collections.go#L417-L453","documentation":"Thrown by Seq after cast.ToIntSlice fails to convert all provided arguments to ints, yielding an empty/wrong-length intArgs slice (line 434). Unlike error 107 (raw arity), this fires when the count looks right but the values are non-integer (strings, floats that don't cast, nils, bools).","triggerScenarios":"Calling {{ seq \"a\" \"b\" }}, {{ seq 1.5 5 }}, or {{ seq .Params.x 10 }} where the param is a string. cast.ToIntSlice drops non-int elements, so intArgs ends up outside 1..3.","commonSituations":"Front matter params typed as strings being fed into seq; floats where ints are needed; nil values from missing params; YAML auto-typing producing strings.","solutions":["Ensure all seq arguments are integers: quote-check front matter (use bare numbers) or cast explicitly.","Default and coerce: {{ seq (int .Params.start | default 1) 10 }}.","Validate param types in content; numbers should not be quoted in YAML/TOML."],"exampleFix":"// before\n{{ seq .Params.start 10 }}\n// after\n{{ seq (int (.Params.start | default 1)) 10 }}","handlingStrategy":"validation","validationCode":"{{ seq (int (.Params.start | default 1)) (int (.Params.end | default 10)) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Coerce all seq arguments to int with the int function.","Keep numbers unquoted in front matter so YAML parses them as ints.","Default missing params before casting."],"tags":["hugo","template","collections","seq","type-coercion","argument-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}