AdguardTeam/AdGuardHome · warning

expired session: %w

Error message

expired session: %w

What it means

FindByToken found a session that is expired, attempted to delete it via deleteByToken, and that deletion itself failed. The wrapped error comes from remove() (begin/rollback/delete/commit chain). The user-visible effect is that expired sessions cannot be purged from the db.

Source

Thrown at internal/aghuser/sessionstorage.go:393

	return nil
}

// FindByToken implements the [SessionStorage] interface for *DefaultSessionStorage.
func (ds *DefaultSessionStorage) FindByToken(ctx context.Context, t SessionToken) (s *Session, err error) {
	ds.mu.Lock()
	defer ds.mu.Unlock()

	s, ok := ds.sessions[t]
	if !ok {
		return nil, nil
	}

	now := ds.clock.Now()
	if now.After(s.Expire) {
		err = ds.deleteByToken(ctx, t)
		if err != nil {
			return nil, fmt.Errorf("expired session: %w", err)
		}

		return nil, nil
	}

	return s, nil
}

// DeleteByToken implements the [SessionStorage] interface for
// *DefaultSessionStorage.
func (ds *DefaultSessionStorage) DeleteByToken(ctx context.Context, t SessionToken) (err error) {
	ds.mu.Lock()
	defer ds.mu.Unlock()

	// Don't wrap the error because it's informative enough as is.
	return ds.deleteByToken(ctx, t)
}

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Restore writability of the data directory (space, permissions, locks)
  2. Ensure only one process owns the db file
  3. If the db file was removed manually while running, restart the service to reopen it
Defensive patterns

Strategy: try-catch

Try / catch

// expired-session cleanup failure should not fail the request; treat as anonymous
if err != nil && strings.Contains(err.Error(), "expired session") { return nil, aghauth.ErrNoUser }

Prevention

When it happens

Trigger: A request presents an expired session token while the db is unwritable, locked, or the bucket is missing ('no bucket').

Common situations: Disk full or read-only; second instance locking the db; sessions.db deleted out from under a running process so the bucket no longer exists.

Related errors


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