gohugoio/hugo · error
invalid number of arguments to Seq
Error message
invalid number of arguments to Seq
What it means
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.
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.
Example fix
// before
{{ seq 1 2 3 4 }}
// after
{{ seq 1 2 3 }} Defensive patterns
Strategy: validation
Validate before calling
// Ensure 1-3 integer args:
{{ seq 5 }} {{/* 1 arg: 1..5 */}}
{{ seq 2 6 }} {{/* 2 args: 2..6 */}}
{{ seq 1 2 9 }} {{/* 3 args: 1,3,5,7,9 */}} Prevention
- 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.
When it happens
Trigger: 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...)).
Common situations: 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.
Related errors
- complement needs at least two arguments
- invalid arguments to Seq
- both count and seq must be provided
- can't evaluate the array by no match argument or more than…
- cannot index slice/array with nil
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/fe83b5aded1ff4c7.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/collections/collections.go:430
}
// Sanity check for slices created by Seq and D.
const maxSeqSize = 1000000
var errSeqSizeExceedsLimit = errors.New("size of result exceeds limit")
// Seq creates a sequence of integers from args. It's named and used as GNU's seq.
//
// Examples:
//
// 3 => 1, 2, 3
// 1 2 4 => 1, 3
// -3 => -1, -2, -3
// 1 4 => 1, 2, 3, 4
// 1 -2 => 1, 0, -1, -2
func (ns *Namespace) Seq(args ...any) ([]int, error) {
if len(args) < 1 || len(args) > 3 {
return nil, errors.New("invalid number of arguments to Seq")
}
intArgs := cast.ToIntSlice(args)
if len(intArgs) < 1 || len(intArgs) > 3 {
return nil, errors.New("invalid arguments to Seq")
}
inc := 1
var last int
first := intArgs[0]
if len(intArgs) == 1 {
last = first
if last == 0 {
return []int{}, nil
} else if last > 0 {
first = 1
} else {View on GitHub (pinned to 52c9bd7908)