{"record":{"id":"71314d131957e592","repo":"gohugoio/hugo","slug":"wrong-number-of-args-for-s-got-d-want-d","errorCode":null,"errorMessage":"wrong number of args for %s: got %d want %d","messagePattern":"wrong number of args for (.+?): got (.+?) want (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/internal/go_templates/texttemplate/funcs.go","lineNumber":334,"sourceCode":"\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 {\n\t\t\treturn reflect.Value{}, fmt.Errorf(\"arg %d: %w\", i, err)\n\t\t}\n\t}\n\treturn safeCall(fn, argv)\n}","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/internal/go_templates/texttemplate/funcs.go#L316-L352","documentation":"Raised by the `call` action for a non-variadic function when the argument count does not equal `numIn` (funcs.go:333-334). Non-variadic funcs require an exact arity match. Format: `name got want`.","triggerScenarios":"`{{call .Fn 1 2}}` on `func(int) int`; calling a method with the wrong number of args; refactoring a helper to add/remove a parameter without updating templates.","commonSituations":"Signature drift after a refactor; template written against an older version of the func; passing a pipeline arg that adds an unexpected operand.","solutions":["Match the exact argument count declared in Go.","Check the FuncMap/method signature and align the call site.","Use a wrapper with optional defaults if the call sites vary."],"exampleFix":"// before\n{{call .Add 1 2 3}}   // func(int, int) int\n\n// after\n{{call .Add 1 2}}","handlingStrategy":"validation","validationCode":"// Match exact arity for non-variadic funcs:\n//   {{call .Add 1 2}}   // func(int, int) int\n// Audit call sites when refactoring a func's parameter list.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep call-site arg counts aligned with declared signatures.","When changing a func signature, search templates for callers.","Use wrapper funcs with defaults to absorb signature changes."],"tags":["template","call","arity","text-template"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}