{"record":{"id":"89e289404fb55ce0","repo":"gohugoio/hugo","slug":"too-many-arguments","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/strings/strings.go","lineNumber":340,"sourceCode":"\t}\n\n\tvar argStart, argEnd int\n\n\targNum := len(startEnd)\n\n\tif argNum > 0 {\n\t\tif argStart, err = cast.ToIntE(startEnd[0]); err != nil {\n\t\t\treturn \"\", errors.New(\"start argument must be integer\")\n\t\t}\n\t}\n\tif argNum > 1 {\n\t\tif argEnd, err = cast.ToIntE(startEnd[1]); err != nil {\n\t\t\treturn \"\", errors.New(\"end argument must be integer\")\n\t\t}\n\t}\n\n\tif argNum > 2 {\n\t\treturn \"\", errors.New(\"too many arguments\")\n\t}\n\n\tasRunes := []rune(aStr)\n\n\tif argNum > 0 && (argStart < 0 || argStart >= len(asRunes)) {\n\t\treturn \"\", errors.New(\"slice bounds out of range\")\n\t}\n\n\tif argNum == 2 {\n\t\tif argEnd < 0 || argEnd > len(asRunes) {\n\t\t\treturn \"\", errors.New(\"slice bounds out of range\")\n\t\t}\n\t\treturn string(asRunes[argStart:argEnd]), nil\n\t} else if argNum == 1 {\n\t\treturn string(asRunes[argStart:]), nil\n\t} else {\n\t\treturn string(asRunes[:]), nil\n\t}","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/strings/strings.go#L322-L358","documentation":"Thrown by strings.SliceString when more than two index arguments are passed. SliceString accepts at most a start and an end index; a third index or more is a usage error.","triggerScenarios":"Calling {{ strings.SliceString $s 0 5 10 }} or any call with three or more indices.","commonSituations":"Copy-paste from a function that takes more args; misunderstanding that SliceString is a half-open two-index range; passing a slice of indices.","solutions":["Pass at most two indices: {{ strings.SliceString $s $start $end }}.","Use a single index to slice to the end: {{ strings.SliceString $s $start }}.","If you need a step, chain SliceString calls instead."],"exampleFix":"// before\n{{ strings.SliceString $s 0 5 10 }}\n// after\n{{ strings.SliceString $s 0 5 }}","handlingStrategy":"validation","validationCode":"{{ strings.SliceString $s $start $end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass at most two indices to SliceString.","Use a single index to slice to the end.","Chain calls instead of passing a step argument."],"tags":["template","strings","arguments","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}