gohugoio/hugo · error

invalid arguments to Seq

Error message

invalid arguments to Seq

What it means

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).

Source

Thrown at tpl/collections/collections.go:435

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 {
			first = -1
			inc = -1
		}
	} else if len(intArgs) == 2 {
		last = intArgs[1]

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Ensure all seq arguments are integers: quote-check front matter (use bare numbers) or cast explicitly.
  2. Default and coerce: {{ seq (int .Params.start | default 1) 10 }}.
  3. Validate param types in content; numbers should not be quoted in YAML/TOML.

Example fix

// before
{{ seq .Params.start 10 }}
// after
{{ seq (int (.Params.start | default 1)) 10 }}
Defensive patterns

Strategy: validation

Validate before calling

{{ seq (int (.Params.start | default 1)) (int (.Params.end | default 10)) }}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/3ee03c90b70839bc. Report an issue: GitHub.