{"record":{"id":"e38197741d6bebca","repo":"dgraph-io/badger","slug":"cannot-open-db-because-the-external-magic-number-d","errorCode":null,"errorMessage":"cannot open DB because the external magic number doesn't match, expected: %d, version present in manifest: %d","messagePattern":"cannot open DB because the external magic number doesn't match, expected: (.+?), version present in manifest: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"manifest.go","lineNumber":377,"sourceCode":"\t}\n\tif !bytes.Equal(magicBuf[0:4], magicText[:]) {\n\t\treturn Manifest{}, 0, errBadMagic\n\t}\n\n\textVersion := y.BytesToU16(magicBuf[4:6])\n\tversion := y.BytesToU16(magicBuf[6:8])\n\n\tif version != badgerMagicVersion {\n\t\treturn Manifest{}, 0,\n\t\t\t//nolint:lll\n\t\t\tfmt.Errorf(\"manifest has unsupported version: %d (we support %d).\\n\"+\n\t\t\t\t\"Please see https://github.com/dgraph-io/badger/blob/main/docs/troubleshooting.md#i-see-manifest-has-unsupported-version-x-we-support-y-error\"+\n\t\t\t\t\" on how to fix this\",\n\t\t\t\tversion, badgerMagicVersion)\n\t}\n\tif extVersion != extMagic {\n\t\treturn Manifest{}, 0,\n\t\t\tfmt.Errorf(\"cannot open DB because the external magic number doesn't match, \"+\n\t\t\t\t\"expected: %d, version present in manifest: %d\", extMagic, extVersion)\n\t}\n\n\tstat, err := fp.Stat()\n\tif err != nil {\n\t\treturn Manifest{}, 0, err\n\t}\n\n\tbuild := createManifest()\n\tvar offset int64\n\tfor {\n\t\toffset = r.count\n\t\tvar lenCrcBuf [8]byte\n\t\t_, err := io.ReadFull(&r, lenCrcBuf[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF || err == io.ErrUnexpectedEOF {\n\t\t\t\tbreak\n\t\t\t}","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/manifest.go#L359-L395","documentation":"Returned by ReplayManifestFile when the external magic number stored in the MANIFEST header (bytes 4:6) does not equal the extMagic value the caller passed for this database flavor (e.g. a normal DB vs. an encryption/key-registry variant reading the same file). It means the MANIFEST on disk belongs to a different Badger variant or was written with an incompatible external identifier, so the file cannot be interpreted safely. Distinct from the internal version check: both version fields must match their expected constants.","triggerScenarios":"Thrown at manifest.go:377 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm you are opening the database with the same Badger build/variant that created it (e.g. not mixing a tool built with different external magic constants)","Upgrade or pin the badger package to the exact version that produced the directory","If the directory was created by an incompatible tool, dump the data with that tool and re-import via a database created by the current binary","If the MANIFEST is simply corrupt (random ext bytes), restore it from backup or recreate the database"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a001d466f6b71a917319a1db41f99860e16e269","analyzedAt":"2026-09-05T13:00:02.264Z","contentChangedAt":"2026-09-05T13:00:02.264Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}