{"record":{"id":"6aa7ef8d592d2152","repo":"gohugoio/hugo","slug":"both-limit-and-seq-must-be-provided","errorCode":null,"errorMessage":"both limit and seq must be provided","messagePattern":"both limit and seq must be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/collections.go","lineNumber":67,"sourceCode":"\t\tloc:      loc,\n\t\tsortComp: compare.New(loc, true),\n\t\tdCache:   dCache,\n\t\tdeps:     deps,\n\t}\n}\n\n// Namespace provides template functions for the \"collections\" namespace.\ntype Namespace struct {\n\tloc      *time.Location\n\tsortComp *compare.Namespace\n\tdCache   *hmaps.Cache[dKey, []int]\n\tdeps     *deps.Deps\n}\n\n// After returns all the items after the first n items in list l.\nfunc (ns *Namespace) After(n any, l any) (any, error) {\n\tif n == nil || l == nil {\n\t\treturn nil, errors.New(\"both limit and seq must be provided\")\n\t}\n\n\tnv, err := cast.ToIntE(n)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif nv < 0 {\n\t\treturn nil, errors.New(\"sequence bounds out of range [\" + cast.ToString(nv) + \":]\")\n\t}\n\n\tlv := reflect.ValueOf(l)\n\tlv, isNil := hreflect.Indirect(lv)\n\tif isNil {\n\t\treturn nil, errors.New(\"can't iterate over a nil value\")\n\t}\n\n\tswitch lv.Kind() {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/collections/collections.go#L49-L85","documentation":"After (collections.go:65-68) requires both a limit (n) and a sequence (l); if either is nil it stops immediately. Literal nil is the trigger here (typed-nil is caught later at line 82 with a different message).","triggerScenarios":"{{ after 5 nil }}, {{ after nil .Pages }}, or {{ nil | after 5 }} (note pipe makes nil the first positional arg = n).","commonSituations":"A frontmatter param used as limit that defaulted to nil; a missing page-collection variable passed as the list; reversed pipe argument order.","solutions":["Provide concrete non-nil values for both limit and list","Guard: {{ with $list }}{{ after 5 . }}{{ end }}","Default the limit: {{ after (default $n 5) $list }}"],"exampleFix":"// before\n{{ after 5 $maybeNil }}\n// after\n{{ with $maybeNil }}{{ after 5 . }}{{ end }}","handlingStrategy":"validation","validationCode":"{{ with $list }}\n  {{ after (default $n 5) . }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide concrete non-nil limit and list","Remember the pipe target becomes the first positional arg, so mind order","Default optional params with (default $v 5)"],"tags":["hugo","go-template","collections","nil-check","argument-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}