{"record":{"id":"e492307931e3eb15","repo":"nats-io/nats-server","slug":"10062","errorCode":"10062","errorMessage":"restore for stream '%s > %s' did not create a stream","messagePattern":"restore for stream '(.+?) > (.+?)' did not create a stream","errorType":"error_code","errorClass":"JSStreamRestoreError","httpStatus":500,"severity":"critical","filePath":"server/jetstream_api.go","lineNumber":4375,"sourceCode":"\t\t\t\t},\n\t\t\t\tStream: streamName,\n\t\t\t\tStart:  start,\n\t\t\t\tEnd:    end,\n\t\t\t\tBytes:  int64(total),\n\t\t\t\tClient: ci.forAdvisory(),\n\t\t\t\tDomain: domain,\n\t\t\t})\n\n\t\t\tvar resp = JSApiStreamCreateResponse{ApiResponse: ApiResponse{Type: JSApiStreamCreateResponseType}}\n\t\t\tif err != nil {\n\t\t\t\tif IsNatsErr(err, JSStorageResourcesExceededErr, JSMemoryResourcesExceededErr) {\n\t\t\t\t\ts.resourcesExceededError(cfg.Storage)\n\t\t\t\t}\n\t\t\t\tresp.Error = NewJSStreamRestoreError(err, Unless(err))\n\t\t\t\ts.Warnf(\"Restore failed for %s for stream '%s > %s' in %v\",\n\t\t\t\t\tfriendlyBytes(int64(total)), acc.Name, streamName, end.Sub(start))\n\t\t\t} else if mset == nil {\n\t\t\t\terr = fmt.Errorf(\"restore for stream '%s > %s' did not create a stream\", acc.Name, streamName)\n\t\t\t\tresp.Error = NewJSStreamRestoreError(err)\n\t\t\t\ts.Warnf(\"Restore failed for %s for stream '%s > %s' in %v\",\n\t\t\t\t\tfriendlyBytes(int64(total)), acc.Name, streamName, end.Sub(start))\n\t\t\t} else {\n\t\t\t\tmsetCfg := mset.config()\n\t\t\t\tresp.StreamInfo = &StreamInfo{\n\t\t\t\t\tCreated:   mset.createdTime(),\n\t\t\t\t\tState:     mset.state(),\n\t\t\t\t\tConfig:    *setDynamicStreamMetadata(&msetCfg),\n\t\t\t\t\tTimeStamp: time.Now().UTC(),\n\t\t\t\t}\n\t\t\t\ts.Noticef(\"Completed restore of %s for stream '%s > %s' in %v\",\n\t\t\t\t\tfriendlyBytes(int64(total)), acc.Name, streamName, end.Sub(start).Round(time.Millisecond))\n\t\t\t}\n\t\t\tif reply != _EMPTY_ {\n\t\t\t\ts.sendInternalAccountMsg(acc, reply, s.jsonResponse(&resp))\n\t\t\t}\n\t\t\tdoneCh <- err","sourceCodeStart":4357,"sourceCodeEnd":4393,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/jetstream_api.go#L4357-L4393","documentation":"Internal JetStream restore consistency error (wrapped in JSStreamRestoreError, code 10062). After replaying all restore chunks the server expected a materialized stream, but the stream object was nil — the restore transfer 'succeeded' without actually creating the stream.","triggerScenarios":"Restore completes all chunk deliveries but stream creation/assignment fails silently or is aborted server-side (e.g. during clustering the meta/asset assignment did not finish), leaving mset nil at the end of the restore handler.","commonSituations":"Clustered JetStream where the restore's underlying assignment failed or was lost; interrupted restores retried concurrently; server bugs during restore of large streams in clustered mode.","solutions":["Retry the restore from the beginning after confirming the stream does not exist","Check nats-server logs ('Restore failed for ...') and cluster state for assignment failures; fix clustering issues first","Delete any partial stream state and re-run the restore; if reproducible, report/upgrade nats-server"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check: stream must not exist and cluster must be healthy before restoring\nif streamExists(name) || !jetstreamClusterHealthy() {\n\treturn fmt.Errorf(\"preconditions unmet for restore of %s\", name)\n}","typeGuard":null,"tryCatchPattern":"err := restoreStream(cfg, r)\nif err != nil && strings.Contains(err.Error(), \"did not create a stream\") {\n\ttime.Sleep(backoff)\n\tdeletePartialStream(name)\n\treturn restoreStream(cfg, r) // bounded retry\n}","preventionTips":["Verify clustered JetStream meta/asset health before large restores","Avoid concurrent restore attempts for the same stream","Keep nats-server updated; this indicates an internal restore failure path"],"tags":["jetstream","stream-restore","clustering","nats-server"],"backgroundTag":"stream-restore-failed","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}