{"record":{"id":"7d27287203626701","repo":"gohugoio/hugo","slug":"wrong-number-of-args-for-s-got-d-want-at-least","errorCode":null,"errorMessage":"wrong number of args for %s: got %d want at least %d","messagePattern":"wrong number of args for (.+?): got (.+?) want at least (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/internal/go_templates/texttemplate/funcs.go","lineNumber":329,"sourceCode":"// The function must return 1 result, or 2 results, the second of which is an error.\nfunc call(name string, fn reflect.Value, args ...reflect.Value) (reflect.Value, error) {\n\tfn = indirectInterface(fn)\n\tif !fn.IsValid() {\n\t\treturn reflect.Value{}, fmt.Errorf(\"call of nil\")\n\t}\n\ttyp := fn.Type()\n\tif typ.Kind() != reflect.Func {\n\t\treturn reflect.Value{}, fmt.Errorf(\"non-function %s of type %s\", name, typ)\n\t}\n\n\tif err := goodFunc(name, typ); err != nil {\n\t\treturn reflect.Value{}, err\n\t}\n\tnumIn := typ.NumIn()\n\tvar dddType reflect.Type\n\tif typ.IsVariadic() {\n\t\tif len(args) < numIn-1 {\n\t\t\treturn reflect.Value{}, fmt.Errorf(\"wrong number of args for %s: got %d want at least %d\", name, len(args), numIn-1)\n\t\t}\n\t\tdddType = typ.In(numIn - 1).Elem()\n\t} else {\n\t\tif len(args) != numIn {\n\t\t\treturn reflect.Value{}, fmt.Errorf(\"wrong number of args for %s: got %d want %d\", name, len(args), numIn)\n\t\t}\n\t}\n\targv := make([]reflect.Value, len(args))\n\tfor i, arg := range args {\n\t\targ = indirectInterface(arg)\n\t\t// Compute the expected type. Clumsy because of variadics.\n\t\targType := dddType\n\t\tif !typ.IsVariadic() || i < numIn-1 {\n\t\t\targType = typ.In(i)\n\t\t}\n\n\t\tvar err error\n\t\tif argv[i], err = prepareArg(arg, argType); err != nil {","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/internal/go_templates/texttemplate/funcs.go#L311-L347","documentation":"Raised by the `call` action when invoking a variadic function with fewer than `numIn-1` arguments (funcs.go:327-329). A variadic `func(a string, fs ...int)` needs at least one positional arg (the variadic may be empty, but fixed params must be present). Format: `name got wantAtLeast`.","triggerScenarios":"`{{call .VariadicFn}}` with no args when the function has a required leading parameter; `{{partial}}` wrappers that drop a required arg before forwarding to a variadic builtin.","commonSituations":"Registering a custom variadic template func and forgetting that the non-variadic params are mandatory; version bumps adding a required param to an existing variadic helper.","solutions":["Supply at least `numIn-1` args: pass the required positional parameters.","Update the FuncMap entry or the call site to match the new signature.","Add a default in a thin wrapper func so callers can omit it."],"exampleFix":"// before\n{{myJoin}}            // func(sep string, parts ...string)\n\n// after\n{{myJoin \",\"}}","handlingStrategy":"validation","validationCode":"// Pass at least numIn-1 args (fixed params) for variadic funcs:\n//   {{myJoin \",\" \"a\" \"b\"}}   // func(sep string, parts ...string)\n// When unsure, check the func signature in Go.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember variadic funcs still require all fixed parameters.","Document required args on custom FuncMap entries.","Wrap variadic funcs that gain a new required param to preserve call sites."],"tags":["template","call","variadic","text-template"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}