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
- Read the type and value in the message to locate the panic origin
- Reproduce with a debugger or with the deferred recover removed to get the stack
- 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
- Never panic with non-error values in shared code paths
- Log recovered panics with stack traces
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
- panic: %w
- %s: parsing interval: %s
- %s: must be a multiple of 1 hour
- unsupported interval: %w
- opening database: %w
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/66221abeff2a3827.
Report an issue: GitHub.