{"record":{"id":"cc62efb988cf5656","repo":"dgraph-io/badger","slug":"unable-to-parse-log-id","errorCode":null,"errorMessage":"Unable to parse log id.","messagePattern":"Unable to parse log id\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"value.go","lineNumber":506,"sourceCode":"}\n\nfunc (vlog *valueLog) populateFilesMap() error {\n\tvlog.filesMap = make(map[uint32]*logFile)\n\n\tfiles, err := os.ReadDir(vlog.dirPath)\n\tif err != nil {\n\t\treturn errFile(err, vlog.dirPath, \"Unable to open log dir.\")\n\t}\n\n\tfound := make(map[uint64]struct{})\n\tfor _, file := range files {\n\t\tif !strings.HasSuffix(file.Name(), \".vlog\") {\n\t\t\tcontinue\n\t\t}\n\t\tfsz := len(file.Name())\n\t\tfid, err := strconv.ParseUint(file.Name()[:fsz-5], 10, 32)\n\t\tif err != nil {\n\t\t\treturn errFile(err, file.Name(), \"Unable to parse log id.\")\n\t\t}\n\t\tif _, ok := found[fid]; ok {\n\t\t\treturn errFile(err, file.Name(), \"Duplicate file found. Please delete one.\")\n\t\t}\n\t\tfound[fid] = struct{}{}\n\n\t\tlf := &logFile{\n\t\t\tfid:      uint32(fid),\n\t\t\tpath:     vlog.fpath(uint32(fid)),\n\t\t\tregistry: vlog.db.registry,\n\t\t}\n\t\tvlog.filesMap[uint32(fid)] = lf\n\t\tif vlog.maxFid < uint32(fid) {\n\t\t\tvlog.maxFid = uint32(fid)\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/value.go#L488-L524","documentation":"Thrown by valueLog.populateFilesMap (value.go:506) when a file ending in .vlog exists in the value-log directory but its name before the .vlog suffix is not a valid uint32 (strconv.ParseUint fails). The numeric file ID is required to register the file in filesMap, so Open() aborts.","triggerScenarios":"A file like 'abc.vlog', '001.vlog' with stray characters, a file with a trailing space or '.vlog.vlog', or an id exceeding uint32 (e.g. '99999999999.vlog') sits in the vlog directory when badger.Open runs.","commonSituations":"Users manually renaming or creating placeholder .vlog files, rsync/scp artifacts, id field larger than 32 bits from tampering or tooling, tmp files copied in during a botched restore.","solutions":["List the vlog dir and rename or remove the offending non-numeric .vlog file (keeping only valid '<uint32>.vlog' names).","Restore the original file name from backup if it was accidentally renamed.","If the id exceeds uint32, the file was created outside badger's scheme — move it out of the directory and confirm with backups that no valid data is lost.","Check for hidden characters/whitespace in filenames (ls | cat -A) and correct them."],"exampleFix":"// before\n$ ls vlogdir\nbadger-manual-copy.vlog  3.vlog\n// after\n$ mv vlogdir/badger-manual-copy.vlog /tmp/  # remove/rename invalid file\n$ ls vlogdir\n3.vlog","handlingStrategy":"validation","validationCode":"// scan vlog dir for non-numeric *.vlog names before opening badger\nfunc validateVlogNames(dir string) error {\n    files, err := os.ReadDir(dir)\n    if err != nil { return err }\n    for _, f := range files {\n        name := f.Name()\n        if !strings.HasSuffix(name, \".vlog\") { continue }\n        if _, err := strconv.ParseUint(name[:len(name)-5], 10, 32); err != nil {\n            return fmt.Errorf(\"invalid vlog filename %q: %w\", name, err)\n        }\n    }\n    return nil\n}","typeGuard":"func isValidVlogName(name string) bool {\n    if !strings.HasSuffix(name, \".vlog\") { return false }\n    _, err := strconv.ParseUint(strings.TrimSuffix(name, \".vlog\"), 10, 32)\n    return err == nil\n}","tryCatchPattern":"if err := validateVlogNames(vlogDir); err != nil {\n    // quarantine the bad file instead of failing Open\n    os.Rename(filepath.Join(vlogDir, badName), filepath.Join(vlogDir, \"quarantine\", badName))\n}\ndb, err := badger.Open(opts)","preventionTips":["Never place arbitrary files ending in .vlog in the badger data directory.","After restores, validate filenames match '^\\d+\\.vlog$' before opening.","Avoid manual renames of vlog files; use badger's documented recovery procedures.","Watch for tooling (scp, editors) that appends suffixes or spaces to filenames."],"tags":["go","badger","value-log","filename","config"],"backgroundTag":"invalid-filename-format","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"}