{"record":{"id":"dcf853ed6c554de9","repo":"kataras/iris","slug":"unsupported-type-t","errorCode":null,"errorMessage":"unsupported type: %T","messagePattern":"unsupported type: %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"middleware/basicauth/user.go","lineNumber":131,"sourceCode":"\t\telem := v.Interface()\n\t\tswitch m := elem.(type) {\n\t\tcase map[string]string:\n\t\t\treturn userMap(m, opts...)\n\t\tcase map[string]any:\n\t\t\tusername, password, ok := mapUsernameAndPassword(m)\n\t\t\tif !ok {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcp[username] = &user{\n\t\t\t\tpassword: password,\n\t\t\t\tref:      m,\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"unsupported type of map: %T\", users))\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unsupported type: %T\", users))\n\t}\n\n\toptions := toUserAuthOptions(opts)\n\n\treturn func(_ *context.Context, username, password string) (any, bool) {\n\t\tif u, ok := cp[username]; ok { // fast map access,\n\t\t\tif options.ComparePassword(u.password, password) {\n\t\t\t\treturn u.ref, true\n\t\t\t}\n\t\t}\n\n\t\treturn nil, false\n\t}\n}\n\nfunc userMap(usernamePassword map[string]string, opts ...UserAuthOption) AuthFunc {\n\toptions := toUserAuthOptions(opts)\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/middleware/basicauth/user.go#L113-L149","documentation":"This is the outer default branch of AllowUsers: it panics when the `users` argument is neither a slice nor a recognized map type after reflect unwrapping. The library only supports the documented forms (map[string]string, map[string]any, []map[string]any, []User-like structs), so anything else is rejected at startup.","triggerScenarios":"Calling AllowUsers(nil), AllowUsers(\"user:pass\"), AllowUsers(someStruct{}) (a single struct, not a slice), or AllowUsers(&notASliceOfUsers). A nil pointer to a slice passes reflect.Indirect but a nil untyped argument does not match any case.","commonSituations":"Passing nil because the users variable was never loaded; passing one user struct instead of a slice; passing a JSON-decoded value typed as any that turned out to be a string or number.","solutions":["Ensure the argument is non-nil and is one of: map[string]string, map[string]any, or a slice of users/structs.","Wrap a single user struct in a slice: AllowUsers([]MyUser{u}).","Check that the config value feeding AllowUsers was actually decoded (log %T of the value before calling)."],"exampleFix":"// before\nbasicauth.AllowUsers(nil)\n// after\nif users == nil {\n    log.Fatal(\"no users configured\")\n}\nbasicauth.AllowUsers(users) // map[string]string, map[string]any, or slice","handlingStrategy":"validation","validationCode":"if users == nil {\n    return errors.New(\"basicauth: users must not be nil\")\n}\nrv := reflect.Indirect(reflect.ValueOf(users))\nif rv.Kind() != reflect.Slice && rv.Kind() != reflect.Map {\n    return fmt.Errorf(\"basicauth: users must be slice or map, got %T\", users)\n}","typeGuard":"func isAllowUsersInput(v any) bool {\n    if v == nil { return false }\n    k := reflect.Indirect(reflect.ValueOf(v)).Kind()\n    return k == reflect.Slice || k == reflect.Map\n}","tryCatchPattern":"// construction-time panic; validate before:\nif !isAllowUsersInput(users) { log.Fatalf(\"invalid basicauth users input %T\", users) }\nopts.Allow = basicauth.AllowUsers(users)","preventionTips":["Never pass nil or a single struct; wrap single users in a slice.","Log the %T of the configured value during startup debugging.","Cover middleware construction in a smoke test that runs on every deploy."],"tags":["go","panic","basicauth","type-mismatch","nil-value"],"backgroundTag":"unsupported-users-type","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}