{"record":{"id":"be32c372bad5aab4","repo":"nats-io/nats-server","slug":"failed-to-add-consumer-q-w","errorCode":null,"errorMessage":"failed to add consumer %q: %w","messagePattern":"failed to add consumer %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream_backup.go","lineNumber":442,"sourceCode":"\t\tvar consumer SnapshotConsumerState\n\t\tif err := json.Unmarshal(buf, &consumer); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to decode consumer %q state: %w\", name, err)\n\t\t}\n\t\tif consumer.ConsumerConfig == nil {\n\t\t\treturn nil, fmt.Errorf(\"consumer %q is missing config\", name)\n\t\t}\n\t\tif consumer.ConsumerState == nil {\n\t\t\treturn nil, fmt.Errorf(\"consumer %q is missing state\", name)\n\t\t}\n\t\tisEphemeral := !isDurableConsumer(consumer.ConsumerConfig)\n\t\tif isEphemeral {\n\t\t\t// Keep ephemerals alive and interested until all messages have\n\t\t\t// been restored, then start their normal inactivity lifecycle.\n\t\t\tconsumer.Durable = name\n\t\t}\n\t\to, err := mset.addConsumerForRestore(consumer.ConsumerConfig)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to add consumer %q: %w\", name, err)\n\t\t}\n\t\tif isEphemeral {\n\t\t\tephemerals = append(ephemerals, o)\n\t\t}\n\t\trestoredConsumers = append(restoredConsumers, o)\n\t\to.mu.Lock()\n\t\terr = o.setStoreState(consumer.ConsumerState)\n\t\to.mu.Unlock()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to set consumer %q state: %w\", name, err)\n\t\t}\n\t}\n\n\tstore := mset.store\n\tlseq := nstate.FirstSeq - 1\n\teob := false\n\tmp := int64(s.getOpts().MaxPayload)\n\tfor {","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream_backup.go#L424-L460","documentation":"Emitted during restore when mset.addConsumerForRestore fails to create a consumer from the archived config. The wrapped error typically reflects an invalid or conflicting consumer configuration (e.g. durable name collision, invalid filter subject, or limits rejected on the target stream), aborting the restore of that consumer.","triggerScenarios":"Thrown at server/stream_backup.go:442 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the wrapped error to identify the config field rejected by consumer creation","Check for pre-existing consumers with the same durable name on the target stream and remove them or restore into a clean stream","Verify the archived consumer config is supported by the target server version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}