{"record":{"id":"bd78c2c4b6a5a8e9","repo":"kataras/iris","slug":"expects-one-or-more-input-arguments","errorCode":null,"errorMessage":" expects one or more input arguments","messagePattern":" expects one or more input arguments","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"view/jet.go","lineNumber":144,"sourceCode":"\treturn s\n}\n\n// JetArguments is a type alias of `jet.Arguments`,\n// can be used on `AddFunc$funcBody`.\ntype JetArguments = jet.Arguments\n\n// AddFunc should adds a global function to the jet template set.\nfunc (s *JetEngine) AddFunc(funcName string, funcBody any) {\n\t// if something like \"urlpath\" is registered.\n\tif generalFunc, ok := funcBody.(func(string, ...any) string); ok {\n\t\t// jet, unlike others does not accept a func(string, ...any) string,\n\t\t// instead it wants:\n\t\t// func(JetArguments) reflect.Value.\n\n\t\ts.AddVar(funcName, jet.Func(func(args JetArguments) reflect.Value {\n\t\t\tn := args.NumOfArguments()\n\t\t\tif n == 0 { // no input, don't execute the function, panic instead.\n\t\t\t\tpanic(funcName + \" expects one or more input arguments\")\n\t\t\t}\n\n\t\t\tfirstInput := args.Get(0).String()\n\n\t\t\tif n == 1 { // if only the first argument is given.\n\t\t\t\treturn reflect.ValueOf(generalFunc(firstInput))\n\t\t\t}\n\n\t\t\t// if has variadic.\n\n\t\t\tvariadicN := n - 1\n\t\t\tvariadicInputs := make([]any, variadicN) // except the first one.\n\n\t\t\tfor i := 0; i < variadicN; i++ {\n\t\t\t\tvariadicInputs[i] = args.Get(i + 1).Interface()\n\t\t\t}\n\n\t\t\treturn reflect.ValueOf(generalFunc(firstInput, variadicInputs...))","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/view/jet.go#L126-L162","documentation":"When registering a jet global function via AddVar/AddFunc wrapper, the generated jet.Func panics if it is invoked with zero arguments, because the underlying generalFunc needs at least one input string. The panic message names the function that was called without arguments.","triggerScenarios":"Calling a template-registered function (from AddFunc/AddVar wrapping a func(string) R) with no arguments inside a jet template, e.g. {{ myfunc() }}.","commonSituations":"Template typo omitting the argument; refactor changed the function to require a parameter while templates still call it bare.","solutions":["Pass at least one argument in the template: {{ myfunc(\"x\") }}","Check every template using the function after changing its signature","Add a compile-time/template test that executes all templates at startup to catch this early"],"exampleFix":"// before (template)\n{{ uppercase() }}\n// after\n{{ uppercase(\"name\") }}","handlingStrategy":"validation","validationCode":"// in templates always pass an argument; add a startup template render test\nn := len(args)\nif n == 0 { return fallbackValue } // wrap your jet.Func defensively","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { log.Printf(\"jet func panic: %v\", r); http.Error(w, \"template error\", 500) } }()","preventionTips":["Run template compilation/rendering in CI so missing arguments fail at build time","Keep a registry of global template functions and their required arities","Grep templates for calls to registered funcs and verify each has arguments"],"tags":["go","panic","templates","jet"],"backgroundTag":"template-function-missing-argument","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}