kataras/iris · critical

panic(err)

Error message

panic(err)

What it means

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.

Source

Thrown at auth/auth.go:93

	// and the refresh token if the refresh jwt token id exists in the configuration.
	SigninResponse struct {
		AccessToken  string `json:"access_token"`
		RefreshToken string `json:"refresh_token,omitempty"`
	}

	// RefreshRequest is the request body the server expects
	// on VerifyHandler to renew an access and refresh token pair.
	RefreshRequest struct {
		RefreshToken string `json:"refresh_token"`
	}
)

// MustLoad binds a filename (fullpath) configuration yaml or json
// and constructs a new Auth instance. It panics on error.
func MustLoad[T User](filename string) *Auth[T] {
	var config Configuration
	if err := config.BindFile(filename); err != nil {
		panic(err)
	}

	return Must(New[T](config))
}

// Must is a helper that wraps a call to a function returning (*Auth[T], error)
// and panics if the error is non-nil. It is intended for use in variable
// initializations such as
//
//	var s = auth.Must(auth.New[MyUser](config))
func Must[T User](s *Auth[T], err error) *Auth[T] {
	if err != nil {
		panic(err)
	}

	return s
}

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Verify the filename/fullpath is correct and the file exists and is readable at the location the process runs from.
  2. Validate the YAML/JSON syntax (e.g. yamllint) and that all keys match the expected auth Configuration fields.
  3. If errors should be handled gracefully at startup, call the non-panicking path instead: config.BindFile + auth.New, checking the returned error.

Example fix

// before
auth := auth.MustLoad[User]("conf/auth.yml") // panics if missing
// after
var cfg auth.Configuration
if err := cfg.BindFile("conf/auth.yml"); err != nil {
  log.Fatalf("load auth config: %v", err)
}
a, err := auth.New[User](cfg)
if err != nil { log.Fatal(err) }
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(filename); err != nil {
  log.Fatalf("auth config file missing: %v", err)
}

Try / catch

defer func() {
  if r := recover(); r != nil {
    log.Fatalf("auth.MustLoad failed: %v", r)
  }
}()
a := auth.MustLoad[User](filename)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/28ba69321a3d6ffc. Report an issue: GitHub.