AdguardTeam/AdGuardHome · error

panic: recovered value of type %[1]T: %[1]v

Error message

panic: recovered value of type %[1]T: %[1]v

What it means

withRecovered converts a recovered panic whose value is NOT an error into this formatted error, including the value's type and representation. It is deferred-wrapped onto stats.New's returned error.

Source

Thrown at internal/stats/stats.go:229

	s.logger.Debug("initialized")

	return s, nil
}

// withRecovered turns the value recovered from panic if any into an error and
// combines it with the one pointed by orig.  orig must be non-nil.
func withRecovered(orig *error) {
	p := recover()
	if p == nil {
		return
	}

	var err error
	switch p := p.(type) {
	case error:
		err = fmt.Errorf("panic: %w", p)
	default:
		err = fmt.Errorf("panic: recovered value of type %[1]T: %[1]v", p)
	}

	*orig = errors.WithDeferred(*orig, err)
}

// type check
var _ Interface = (*StatsCtx)(nil)

// Start implements the [Interface] interface for *StatsCtx.
func (s *StatsCtx) Start() {
	s.initWeb()

	go s.periodicFlush()
}

// Close implements the [io.Closer] interface for *StatsCtx.
func (s *StatsCtx) Close() (err error) {
	db := s.db.Swap(nil)

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Read the type and value in the message to locate the panic origin
  2. Reproduce with a debugger or with the deferred recover removed to get the stack
  3. Check inputs to stats.New for nil/invalid fields
Defensive patterns

Strategy: try-catch

Try / catch

defer func() { if r := recover(); r != nil { err = fmt.Errorf("caught %T %v", r, r) } }()

Prevention

When it happens

Trigger: A panic inside stats.New with a non-error value, e.g. panic("string"), panic(int), runtime errors surfaced as non-error values, or nil-map writes that recover as runtime.Error (which is an error) vs custom string panics.

Common situations: Third-party code panicking with strings/structs; internal invariant violations during stats initialization.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/66221abeff2a3827. Report an issue: GitHub.