nats-io/nats-server · error
bad consumer config
Error message
bad consumer config
What it means
Returned by (*fileStore).ConsumerStore when the provided ConsumerConfig is nil or the consumer name is an empty string. The file store cannot create a consumer without a valid name and configuration, so it refuses. This is a caller-contract validation error inside the store layer.
Source
Thrown at server/filestore.go:13335
hh *highwayhash.Digest64
state ConsumerState
fch chan struct{}
qch chan struct{}
flusher bool
writing bool
dirty bool
closed bool
}
func (fs *fileStore) ConsumerStore(name string, created time.Time, cfg *ConsumerConfig) (ConsumerStore, error) {
if fs == nil {
return nil, fmt.Errorf("filestore is nil")
}
if fs.isClosed() {
return nil, ErrStoreClosed
}
if cfg == nil || name == _EMPTY_ {
return nil, fmt.Errorf("bad consumer config")
}
// We now allow overrides from a stream being a filestore type and forcing a consumer to be memory store.
if cfg.MemoryStorage {
// Create directly here.
o := &consumerMemStore{ms: fs, name: name, cfg: *cfg}
if err := fs.AddConsumer(o); err != nil {
return nil, err
}
return o, nil
}
odir := filepath.Join(fs.fcfg.StoreDir, consumerDir, name)
if err := os.MkdirAll(odir, defaultDirPerms); err != nil {
return nil, fmt.Errorf("could not create consumer directory - %v", err)
}
csi := &FileConsumerInfo{Name: name, Created: created, ConsumerConfig: *cfg}
o := &consumerFileStore{View on GitHub (pinned to 3a66a489d2)
Solutions
- Ensure the consumer create request includes a valid durable name and full ConsumerConfig.
- Inspect the stream's consumer directory meta files; restore missing/corrupt JetStreamMetaFile entries from backup.
- Re-create the consumer via the JetStream API after fixing the request.
- Remove orphaned consumer directories whose config cannot be loaded, then re-add the consumer.
Example fix
// before
fs.ConsumerStore("", created, nil)
// after
fs.ConsumerStore("my-durable", created, &ConsumerConfig{Durable: "my-durable", AckPolicy: AckExplicit}) Defensive patterns
Strategy: validation
Validate before calling
func validConsumerReq(name string, cfg *ConsumerConfig) bool {
return name != "" && cfg != nil && cfg.Durable == name
} Type guard
func cfgOk(cfg *ConsumerConfig) bool { return cfg != nil } Try / catch
if err != nil {
if strings.Contains(err.Error(), "bad consumer config") {
// fix request: supply durable name and full ConsumerConfig, then retry
}
} Prevention
- Always set Durable and pass a complete ConsumerConfig
- Never hand-edit JetStream consumer meta files
- Use the official JetStream API/clients to create consumers
- Validate restored stream directories before restarting the server
When it happens
Trigger: Calling ConsumerStore with cfg == nil or name == ""; internally this means JetStream attempted to materialize a consumer without a valid name/config, typically from a corrupted or hand-edited consumer meta file or an API request missing required fields.
Common situations: Malformed consumer create API requests missing the durable name/stream config; restored or manually edited JetStream meta files missing ConsumerConfig; bugs in tooling that manipulates stream state.
Related errors
- bad ack floor for consumer
- could not create consumer directory - %v
- bad ack floor for stream
- bad pending entry, sequence [%d] out of range
- uncompressed buffer is too short
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/10e5679898134cf6.
Report an issue: GitHub.