{"record":{"id":"9fe11d8b15df7004","repo":"nats-io/nats-server","slug":"stream-names-do-not-match","errorCode":null,"errorMessage":"stream names do not match","messagePattern":"stream names do not match","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream.go","lineNumber":9414,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Check metadata.\n\t// The cfg passed in will be the new identity for the stream.\n\tvar fcfg FileStreamInfo\n\tb, err := os.ReadFile(filepath.Join(sdir, JetStreamMetaFile))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := json.Unmarshal(b, &fcfg); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Check to make sure names match.\n\tif fcfg.Name != cfg.Name {\n\t\treturn nil, errors.New(\"stream names do not match\")\n\t}\n\n\t// See if this stream already exists.\n\tif _, err := a.lookupStream(cfg.Name); err == nil {\n\t\treturn nil, NewJSStreamNameExistRestoreFailedError()\n\t}\n\t// Move into the correct place here.\n\tndir := filepath.Join(jsa.storeDir, streamsDir, cfg.Name)\n\t// Remove old one if for some reason it is still here.\n\tif _, err := os.Stat(ndir); err == nil {\n\t\tos.RemoveAll(ndir)\n\t}\n\t// Make sure our destination streams directory exists.\n\tif err := os.MkdirAll(filepath.Join(jsa.storeDir, streamsDir), defaultDirPerms); err != nil {\n\t\treturn nil, err\n\t}\n\t// Move into new location.\n\tif err := os.Rename(sdir, ndir); err != nil {","sourceCodeStart":9396,"sourceCodeEnd":9432,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream.go#L9396-L9432","documentation":"During restore, the stream name in the backed-up metadata file (JetStreamMetaFile) differs from the name in the config passed for the restore — the snapshot belongs to a different stream, so the restore is refused before the stream is created.","triggerScenarios":"Thrown at server/stream.go:9414 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore using the same stream name as the backup","Align the metadata and config names if renaming intentionally","Verify the backup directory belongs to the intended stream"],"exampleFix":null,"handlingStrategy":"validation","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"}