kataras/iris · error
func's input arguments should have the same type: [%d] expec
Error message
func's input arguments should have the same type: [%d] expected %s but got %s
What it means
For struct-based macro evaluators, each route argument's parsed value must match the corresponding struct field's Go kind; when kinds differ, registration/route validation panics with 'func's input arguments should have the same type: [%d] expected %s but got %s' (macro/macro.go:216).
Source
Thrown at macro/macro.go:216
val = v
case reflect.Bool:
v, err := strconv.ParseBool(arg)
panicIfErr(i, err)
val = v
case reflect.Slice:
if len(arg) > 1 {
if arg[0] == '[' && arg[len(arg)-1] == ']' {
// it is a single argument but as slice.
val = strings.Split(arg[1:len(arg)-1], ",") // only string slices.
}
}
default:
val = arg
}
argValue := reflect.ValueOf(val)
if expected, got := field.Kind(), argValue.Kind(); expected != got {
panic(fmt.Sprintf("func's input arguments should have the same type: [%d] expected %s but got %s", i, expected, got))
}
argValues = append(argValues, argValue)
}
evalFn := reflect.ValueOf(fn).Call(argValues)[0]
// var evaluator EvaluatorFunc
// // check for typed and not typed
// if _v, ok := evalFn.(EvaluatorFunc); ok {
// evaluator = _v
// } else if _v, ok = evalFn.(func(string) bool); ok {
// evaluator = _v
// }
// return func(paramValue any) bool {
// return evaluator(paramValue)
// }
return evalFnView on GitHub (pinned to 7bedaf55a0)
Solutions
- Ensure each argument value converts to the field's declared kind (int fields get integers, bool fields get true/false, etc.).
- Check argument order against the struct's field order.
- Change the struct field type to match the kind of values you pass in routes.
Example fix
// before
app.Get("/{n:number abc}", h) // abc is not a number
// after
app.Get("/{n:number 42}", h) Defensive patterns
Strategy: validation
Validate before calling
// Ensure each argument parses to the struct field's kind before route registration
var v interface{}
_, err := fmt.Sscanf(arg, "%d", &v) // for int fields
if err != nil {
log.Fatalf("argument %q does not match field kind", arg)
} Prevention
- Match argument literals to field kinds: numbers for int fields, true/false for bool.
- Check argument order when the evaluator struct has mixed field types.
- Cover every param-type usage in route tests.
When it happens
Trigger: Passing a route argument that the evaluator parses into a value whose reflect.Kind differs from the struct field's kind — e.g. an int-typed field receiving a non-integer string, or a bool field given something other than true/false.
Common situations: Writing {n:number abc} (non-numeric text for a numeric field), or swapping argument order so a string lands in an int field in multi-argument evaluators.
Related errors
- iris: switch: hosts: invalid target type: %T
- unexpected "fsOrDir" argument type of %T (string or http.Fil
- HandleError input argument must be a type of func(iris.Conte
- %T does not allow any input arguments from route but got [le
- on field index: %d: %v
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/bd926efff82ace0e.
Report an issue: GitHub.