{"record":{"id":"28ba69321a3d6ffc","repo":"kataras/iris","slug":"panic-err","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"auth/auth.go","lineNumber":93,"sourceCode":"\t// and the refresh token if the refresh jwt token id exists in the configuration.\n\tSigninResponse struct {\n\t\tAccessToken  string `json:\"access_token\"`\n\t\tRefreshToken string `json:\"refresh_token,omitempty\"`\n\t}\n\n\t// RefreshRequest is the request body the server expects\n\t// on VerifyHandler to renew an access and refresh token pair.\n\tRefreshRequest struct {\n\t\tRefreshToken string `json:\"refresh_token\"`\n\t}\n)\n\n// MustLoad binds a filename (fullpath) configuration yaml or json\n// and constructs a new Auth instance. It panics on error.\nfunc MustLoad[T User](filename string) *Auth[T] {\n\tvar config Configuration\n\tif err := config.BindFile(filename); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn Must(New[T](config))\n}\n\n// Must is a helper that wraps a call to a function returning (*Auth[T], error)\n// and panics if the error is non-nil. It is intended for use in variable\n// initializations such as\n//\n//\tvar s = auth.Must(auth.New[MyUser](config))\nfunc Must[T User](s *Auth[T], err error) *Auth[T] {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn s\n}\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/auth/auth.go#L75-L111","documentation":"auth.MustLoad is the panicking variant of loading an auth configuration file and constructing an Auth[T] instance. If the YAML/JSON config file cannot be bound (missing file, bad syntax, schema mismatch), the underlying error from Configuration.BindFile is panic'ed.","triggerScenarios":"Calling auth.MustLoad[MyUser](\"config.yml\") where the file does not exist, is unreadable, is malformed YAML/JSON, or its fields do not match the auth.Configuration schema.","commonSituations":"Wrong file path at startup (relative vs absolute path), deploying without the config file present, hand-edited YAML with indentation errors, renamed config keys after a library upgrade.","solutions":["Verify the filename/fullpath is correct and the file exists and is readable at the location the process runs from.","Validate the YAML/JSON syntax (e.g. yamllint) and that all keys match the expected auth Configuration fields.","If errors should be handled gracefully at startup, call the non-panicking path instead: config.BindFile + auth.New, checking the returned error."],"exampleFix":"// before\nauth := auth.MustLoad[User](\"conf/auth.yml\") // panics if missing\n// after\nvar cfg auth.Configuration\nif err := cfg.BindFile(\"conf/auth.yml\"); err != nil {\n  log.Fatalf(\"load auth config: %v\", err)\n}\na, err := auth.New[User](cfg)\nif err != nil { log.Fatal(err) }","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(filename); err != nil {\n  log.Fatalf(\"auth config file missing: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n  if r := recover(); r != nil {\n    log.Fatalf(\"auth.MustLoad failed: %v\", r)\n  }\n}()\na := auth.MustLoad[User](filename)","preventionTips":["Use absolute config paths resolved at startup","Check file existence before calling MustLoad","Prefer BindFile + New with explicit error handling in servers","Validate YAML syntax in CI"],"tags":["go","panic","config","startup"],"backgroundTag":"config-load-failed","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}