{"record":{"id":"b8fa0c931936259b","repo":"cockroachdb/cockroach","slug":"error-while-processing-file-s","errorCode":null,"errorMessage":"error while processing file %s","messagePattern":"error while processing file (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cli/debug_merge_logs.go","lineNumber":591,"sourceCode":"\t}\n\tfi, err := f.Stat()\n\tif err != nil {\n\t\treturn err\n\t}\n\tsize := fi.Size()\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = r.(error)\n\t\t}\n\t}()\n\toffset := sort.Search(int(size), func(i int) bool {\n\t\tif _, err := f.Seek(int64(i), io.SeekStart); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tvar e logpb.Entry\n\t\td, err := log.NewEntryDecoderWithFormat(f, editMode, format)\n\t\tif err != nil {\n\t\t\tpanic(errors.WithMessagef(err, \"error while processing file %s\", f.Name()))\n\t\t}\n\t\tif err := d.Decode(&e); err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tpanic(errors.WithMessagef(err, \"error while processing file %s\", f.Name()))\n\t\t}\n\t\treturn e.Time >= from.UnixNano()\n\t})\n\tif _, err := f.Seek(int64(offset), io.SeekStart); err != nil {\n\t\treturn err\n\t}\n\tvar e logpb.Entry\n\td, err := log.NewEntryDecoderWithFormat(f, editMode, format)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := d.Decode(&e); err != nil {","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/cockroachdb/cockroach/blob/8812064a015d2faf99d3fc7e15880f94042954b0/pkg/cli/debug_merge_logs.go#L573-L609","documentation":"In `cockroach debug merge-logs`, finding the start offset binary-searches each file (sort.Search) for the first entry with Time >= from. Inside that predicate, log.NewEntryDecoderWithFormat(f, editMode, format) failure panics with 'error while processing file <name>'; the deferred recover() converts the panic into the function's returned error, so the command fails with this message naming the file.","triggerScenarios":"Passing an explicit --format that this binary cannot construct a decoder for (unsupported/unknown format enum), or a file that cannot be decoded under the requested edit mode — the construction happens at arbitrary offsets during the binary search, so a mismatched --format flag fails fast here.","commonSituations":"Running merge-logs with --format=json over files written in the default text format (or vice versa); using --redactable expectations on files that don't match; logs from a much newer version with a changed encoding.","solutions":["Drop the --format flag and let the command auto-detect each file's format","Verify the file is a cockroach log produced by a compatible version (try decoding it standalone with merge-logs on just that file)","Separate inputs by format and run once per group instead of merging mixed encodings","Decompress .gz files first if they are being passed compressed"],"exampleFix":"# before\ncockroach debug merge-logs --format=json node1.log node2.log\n\n# after (auto-detect per file)\ncockroach debug merge-logs node1.log node2.log","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit --format and let merge-logs auto-detect each file","Never mix json and text log files in one merge; group by the node's --log-format","Sanity-decode each file standalone before merging a large set"],"tags":["cli","debug","merge-logs","logging","go"],"backgroundTag":null,"analyzedSha":"8812064a015d2faf99d3fc7e15880f94042954b0","analyzedAt":"2026-08-15T16:34:17.351Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}