t8y2/dbx · error

Not connected

Error message

Not connected

What it means

activeClient guards all etcd RPCs on the session having an established gRPC client. If s.client is nil — i.e. connect was never called or a previous disconnect cleared it — every operation that needs the client fails fast with "Not connected" instead of a confusing nil-pointer panic. It is the session-lifecycle sentinel error of this driver.

Source

Thrown at agents/drivers/etcd-go/client.go:101

		return nil, err
	}
	authEnabled := detectAuthEnabled(nextClient, authUsername)
	s.close()
	s.clientMu.Lock()
	s.client = nextClient
	s.connectedEndpoints = endpointList
	s.username = authUsername
	s.authEnabled = authEnabled
	s.clientMu.Unlock()
	return map[string]bool{"ok": true}, nil
}

func (s *etcdSession) activeClient() (*clientv3.Client, error) {
	s.clientMu.Lock()
	client := s.client
	s.clientMu.Unlock()
	if client == nil {
		return nil, errors.New("Not connected")
	}
	return client, nil
}

func (s *etcdSession) connectedEndpointList() []string {
	s.clientMu.Lock()
	defer s.clientMu.Unlock()
	return append([]string(nil), s.connectedEndpoints...)
}

func (s *etcdSession) validateConnection() (any, error) {
	client, err := s.activeClient()
	if err != nil {
		return nil, err
	}
	return probeClient(client, s.connectedEndpointList())
}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Call connect (or the connect operation) on the session before any data/auth operations.
  2. Check connectivity to the configured etcd endpoints; connect fails if none are reachable.
  3. Re-create the session if it was closed; sessions are not reusable after the client is released.
  4. Verify ETCD_ENDPOINTS/connection config points at a live cluster and probeClient succeeds.

Example fix

// before
session := newEtcdSession(connection)
user, err := session.authUserGet("alice") // Not connected
// after
session := newEtcdSession(connection)
if err := session.connect(); err != nil { return err }
user, err := session.authUserGet("alice")
Defensive patterns

Strategy: validation

Validate before calling

if !session.isConnected() { // or check s.client != nil before calls
	return errors.New("session not connected: call connect() first")
}

Type guard

func (s *etcdSession) isConnected() bool {
	s.clientMu.Lock()
	defer s.clientMu.Unlock()
	return s.client != nil
}

Try / catch

client, err := s.activeClient()
if err != nil {
	if err.Error() == "Not connected" {
		if cerr := s.connect(); cerr != nil {
			return nil, fmt.Errorf("cannot reach etcd: %w", cerr)
		}
		client, err = s.activeClient()
	}
	if err != nil {
		return nil, err
	}
}

Prevention

When it happens

Trigger: Calling readableKeyRanges, authUserList, authUserGet, authUserAdd, authUserDelete, or authUserChangePassword (or history, which calls activeClient first) on an etcdSession whose connect() has not succeeded or whose client was cleared on close.

Common situations: Using an agent before an explicit connect; the etcd server being down so connect never populated the client; a connection dropped/closed and the stale session reused; tests exercising an unconnected session (TestUnconnectedSessionErrors pattern).

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/d7ebd105326f4628. Report an issue: GitHub.