kataras/iris · error

<appName> is not a registered Application

Error message

<appName> is not a registered Application

What it means

context.MustGetApplication looks up a child Application by name in the Iris application registry and panics if no Application with that name is registered (or the stored value is nil). It is the strict counterpart of GetApplication, which returns ok=false instead.

Source

Thrown at context/application.go:205

	mu.RLock()

	for i := len(registeredApps) - 1; i >= 0; i-- {
		if app := registeredApps[i]; app != nil && app.String() == appName {
			mu.RUnlock()
			return app, true
		}
	}

	mu.RUnlock()
	return nil, false
}

// MustGetApplication same as `GetApplication` but it
// panics if "appName" is not a registered Application's name.
func MustGetApplication(appName string) Application {
	app, ok := GetApplication(appName)
	if !ok || app == nil {
		panic(appName + " is not a registered Application")
	}

	return app
}

// DefaultLogger returns a Logger instance for an Iris module.
// If the program contains at least one registered Iris Application
// before this call then it will return a child of that Application's Logger
// otherwise a fresh child of the `golog.Default` will be returned instead.
//
// It should be used when a module has no access to the Application or its Logger.
func DefaultLogger(prefix string) (logger *golog.Logger) {
	if app := LastApplication(); app != nil {
		logger = app.Logger()
	} else {
		logger = golog.Default
	}

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Ensure an application was registered with exactly this name via app.New(iris.Options{Name: ...}) / the children registry before the lookup.
  2. Fix the name string (case-sensitive exact match).
  3. Use the non-panicking GetApplication and handle the ok=false case when the app may legitimately be absent.

Example fix

// before
sub := context.MustGetApplication("admin") // panics if missing
// after
sub, ok := context.GetApplication("admin")
if !ok { log.Fatal("admin app not registered") }
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := context.GetApplication(appName); !ok {
  log.Fatalf("application %q not registered", appName)
}
sub := context.MustGetApplication(appName)

Type guard

func appRegistered(name string) bool {
  app, ok := context.GetApplication(name)
  return ok && app != nil
}

Try / catch

defer func() {
  if r := recover(); r != nil {
    log.Fatalf("MustGetApplication: %v", r)
  }
}()

Prevention

When it happens

Trigger: Calling context.MustGetApplication("appName") where no application was registered under that exact name, e.g. the child app was created with a different name or New was never called with that name before lookup.

Common situations: Typos in application names, lookup happening before the child application registration, or refactoring that renamed apps while other code still references the old name.

Related errors


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