{"record":{"id":"f65255d9c03b2da9","repo":"nats-io/nats-server","slug":"nil-config-on-stream-restore","errorCode":null,"errorMessage":"nil config on stream restore","messagePattern":"nil config on stream restore","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream.go","lineNumber":9305,"sourceCode":"\tif mset.closed.Load() {\n\t\treturn nil, errStreamClosed\n\t}\n\tstore := mset.store\n\t// V2 snapshots intentionally do not run the v1 checkMsgs pre-scan. Unlike\n\t// v1's raw file copy, v2 reads each message through LoadNextMsg, which uses\n\t// cacheLookup/msgFromBufEx and verifies the per-record checksum when a\n\t// freshly loaded cache entry is first read. Corrupt records therefore make\n\t// LoadNextMsg fail and abort the snapshot instead of silently entering the\n\t// backup.\n\treturn mset.js.CreateStreamSnapshotV2(store, deadline, includeConsumers, mset.streamAssignment())\n}\n\nconst snapsDir = \"__snapshots__\"\n\n// RestoreStream will restore a stream from a snapshot.\nfunc (a *Account) RestoreStream(ncfg *StreamConfig, r io.Reader) (*stream, error) {\n\tif ncfg == nil {\n\t\treturn nil, errors.New(\"nil config on stream restore\")\n\t}\n\n\ts, jsa, err := a.checkForJetStream()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tjs := jsa.js\n\tif js == nil {\n\t\treturn nil, NewJSNotEnabledForAccountError()\n\t}\n\n\tcfg, apiErr := s.checkStreamCfg(ncfg, a, false)\n\tif apiErr != nil {\n\t\treturn nil, apiErr\n\t}\n\n\tsd := filepath.Join(jsa.storeDir, snapsDir)\n\tif _, err := os.Stat(sd); os.IsNotExist(err) {","sourceCodeStart":9287,"sourceCodeEnd":9323,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream.go#L9287-L9323","documentation":"Stream restore bookkeeping received a nil StreamConfig where a concrete configuration is required, so the operation aborts instead of dereferencing nil. It signals a caller bug or an incomplete/corrupted restore request, not bad user data.","triggerScenarios":"Thrown at server/stream.go:9305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a fully populated StreamConfig in the restore request","Re-generate the restore backup if its metadata is incomplete","Report as a bug if it occurs while restoring a server-produced snapshot"],"exampleFix":null,"handlingStrategy":"type-guard","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"}