nats-io/nats-server · error
bad consumer config
Error message
bad consumer config
What it means
Validation guard in memStore.ConsumerStore: consumer creation was attempted with a nil ConsumerConfig or an empty consumer name; both are required to instantiate a consumerMemStore.
Source
Thrown at server/memstore.go:2600
type consumerMemStore struct {
mu sync.Mutex
ms StreamStore
name string
cfg ConsumerConfig
state ConsumerState
closed bool
}
func (ms *memStore) ConsumerStore(name string, _ time.Time, cfg *ConsumerConfig) (ConsumerStore, error) {
if ms == nil {
return nil, fmt.Errorf("memstore is nil")
}
if ms.isClosed() {
return nil, ErrStoreClosed
}
if cfg == nil || name == _EMPTY_ {
return nil, fmt.Errorf("bad consumer config")
}
o := &consumerMemStore{ms: ms, name: name, cfg: *cfg}
ms.AddConsumer(o)
return o, nil
}
func (ms *memStore) AddConsumer(o ConsumerStore) error {
ms.mu.Lock()
ms.consumers = append(ms.consumers, o)
ms.mu.Unlock()
return nil
}
func (ms *memStore) RemoveConsumer(o ConsumerStore) error {
ms.mu.Lock()
for i, cfs := range ms.consumers {
if o == cfs {
ms.consumers = append(ms.consumers[:i], ms.consumers[i+1:]...)View on GitHub (pinned to 3a66a489d2)
Solutions
- Provide a non-empty durable/name and a fully populated ConsumerConfig when creating the consumer
- Validate consumer add requests at the JetStream API layer before they reach the store
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/memstore.go:2600 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/30f58b5aa59c99b1.
Report an issue: GitHub.