{"record":{"id":"10e5679898134cf6","repo":"nats-io/nats-server","slug":"bad-consumer-config","errorCode":null,"errorMessage":"bad consumer config","messagePattern":"bad consumer config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":13335,"sourceCode":"\thh      *highwayhash.Digest64\n\tstate   ConsumerState\n\tfch     chan struct{}\n\tqch     chan struct{}\n\tflusher bool\n\twriting bool\n\tdirty   bool\n\tclosed  bool\n}\n\nfunc (fs *fileStore) ConsumerStore(name string, created time.Time, cfg *ConsumerConfig) (ConsumerStore, error) {\n\tif fs == nil {\n\t\treturn nil, fmt.Errorf(\"filestore is nil\")\n\t}\n\tif fs.isClosed() {\n\t\treturn nil, ErrStoreClosed\n\t}\n\tif cfg == nil || name == _EMPTY_ {\n\t\treturn nil, fmt.Errorf(\"bad consumer config\")\n\t}\n\n\t// We now allow overrides from a stream being a filestore type and forcing a consumer to be memory store.\n\tif cfg.MemoryStorage {\n\t\t// Create directly here.\n\t\to := &consumerMemStore{ms: fs, name: name, cfg: *cfg}\n\t\tif err := fs.AddConsumer(o); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn o, nil\n\t}\n\n\todir := filepath.Join(fs.fcfg.StoreDir, consumerDir, name)\n\tif err := os.MkdirAll(odir, defaultDirPerms); err != nil {\n\t\treturn nil, fmt.Errorf(\"could not create consumer directory - %v\", err)\n\t}\n\tcsi := &FileConsumerInfo{Name: name, Created: created, ConsumerConfig: *cfg}\n\to := &consumerFileStore{","sourceCodeStart":13317,"sourceCodeEnd":13353,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L13317-L13353","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nfs.ConsumerStore(\"\", created, nil)\n// after\nfs.ConsumerStore(\"my-durable\", created, &ConsumerConfig{Durable: \"my-durable\", AckPolicy: AckExplicit})","handlingStrategy":"validation","validationCode":"func validConsumerReq(name string, cfg *ConsumerConfig) bool {\n    return name != \"\" && cfg != nil && cfg.Durable == name\n}","typeGuard":"func cfgOk(cfg *ConsumerConfig) bool { return cfg != nil }","tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"bad consumer config\") {\n        // fix request: supply durable name and full ConsumerConfig, then retry\n    }\n}","preventionTips":["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"],"tags":["jetstream","filestore","consumer","validation"],"backgroundTag":"bad-consumer-config","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}