{"record":{"id":"3d4cb3b0fe554bee","repo":"nats-io/nats-server","slug":"stream-assignment-not-present-in-clustered-mode","errorCode":null,"errorMessage":"stream assignment not present in clustered mode","messagePattern":"stream assignment not present in clustered mode","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream_backup.go","lineNumber":141,"sourceCode":"\t\t\tpath.Join(\"consumers\", scs.Name),\n\t\t\tnow.UnixNano(),\n\t\t\t0,\n\t\t\t0,\n\t\t\tint64(len(ssj)),\n\t\t\tssj,\n\t\t)\n\t}\n\n\t// If we aren't including consumers here then make sure the consumer count\n\t// is set accordingly, this helps on the restore path.\n\tvar consumerAssignments map[string]*consumerAssignment\n\tvar consumerStores []ConsumerStore\n\tvar streamState = *state\n\tif !includeConsumers {\n\t\tstreamState.Consumers = 0\n\t} else if clustered {\n\t\tif sa == nil {\n\t\t\terrCh <- errors.New(\"stream assignment not present in clustered mode\")\n\t\t\treturn\n\t\t}\n\t\tjs.mu.RLock()\n\t\tconsumerAssignments = make(map[string]*consumerAssignment, len(sa.consumers))\n\t\tfor name, ca := range sa.consumers {\n\t\t\tconsumerAssignments[name] = ca.copyGroup()\n\t\t}\n\t\tstreamState.Consumers = len(consumerAssignments)\n\t\tjs.mu.RUnlock()\n\t} else {\n\t\tconsumerStores = slices.Collect(store.Consumers())\n\t\tstreamState.Consumers = len(consumerStores)\n\t}\n\n\tssj, err := json.Marshal(streamState)\n\tif err != nil {\n\t\terrCh <- err\n\t\treturn","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream_backup.go#L123-L159","documentation":"In clustered JetStream, streamSnapshotV2 found no stream assignment (sa == nil) for the stream while including consumers — without the assignment, consumer assignments cannot be derived, so the V2 snapshot fails via the error channel. It indicates missing or inconsistent meta-layer state in the cluster.","triggerScenarios":"Thrown at server/stream_backup.go:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the stream has a healthy assignment across meta peers before snapshotting","Retry the snapshot once the cluster meta layer has settled","Rebalance or recreate the stream if its assignment is permanently lost"],"exampleFix":null,"handlingStrategy":"retry","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-08T15:18:49.778Z"}