{"record":{"id":"7175490b364a12cb","repo":"aeron-io/aeron","slug":"invalid-filename-format-filename","errorCode":null,"errorMessage":"invalid filename format: \" + filename","messagePattern":"invalid filename format: \" \\+ filename","errorType":"exception","errorClass":"ArchiveException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/Catalog.java","lineNumber":1196,"sourceCode":"                throw new ArchiveException(\"negative position encoded in the file name: \" + filename);\n            }\n\n            if (filePosition > maxSegmentPosition)\n            {\n                maxSegmentPosition = filePosition;\n                maxFileName = filename;\n            }\n        }\n\n        return maxFileName;\n    }\n\n    static long parseSegmentFilePosition(final String filename)\n    {\n        final int dashOffset = filename.indexOf('-');\n        if (-1 == dashOffset)\n        {\n            throw new ArchiveException(\"invalid filename format: \" + filename);\n        }\n\n        final int positionOffset = dashOffset + 1;\n        final int positionLength = filename.length() - positionOffset - RECORDING_SEGMENT_SUFFIX.length();\n        if (0 >= positionLength)\n        {\n            throw new ArchiveException(\"no position encoded in the segment file: \" + filename);\n        }\n\n        return parseLongAscii(filename, positionOffset, positionLength);\n    }\n\n    static long parseSegmentFileRecordingId(final String filename)\n    {\n        final int dashOffset = filename.indexOf('-');\n        if (-1 == dashOffset || 0 == dashOffset)\n        {\n            throw new InvalidRecordingNameException(\"invalid filename format: \" + filename);","sourceCodeStart":1178,"sourceCodeEnd":1214,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/Catalog.java#L1178-L1214","documentation":"Thrown by Catalog.parseSegmentFilePosition when a recording segment filename does not contain the expected '-' separator between the recordingId and the encoded replay position. The archive relies on the '<recordingId>-<position>.rec' naming convention to recover metadata from segment files, so a file without a dash cannot be parsed.","triggerScenarios":"Parsing a file in the archive catalog directory that is not a well-formed recording segment file (e.g. the catalog itself, temp/partial files, or manually renamed/corrupted segment files missing the dash).","commonSituations":"Corrupted or hand-edited segment filenames after a crash, files copied into the archive directory from elsewhere, or older/newer Aeron versions with different naming schemes sharing one archive directory.","solutions":["Verify the archive directory contains only files matching the '<recordingId>-<position>.rec' segment naming convention","Remove or move out stray files (catalog.dat, partial/temp files) that do not match the segment pattern","Do not manually rename recording segment files; restore them from backup instead","Check that all files came from the same Aeron version (naming scheme changes across versions)"],"exampleFix":"// before: iterating all files and parsing every one\nfor (String f : dir.list()) { pos = Catalog.parseSegmentFilePosition(f); }\n// after: filter to valid segment names first\nfor (String f : dir.list()) {\n    if (f != null && f.matches(\"\\\\d+-\\\\d+\\\\.rec\")) {\n        pos = Catalog.parseSegmentFilePosition(f);\n    }\n}","handlingStrategy":"validation","validationCode":"static boolean isValidSegmentFilename(String f) {\n    return f != null && f.matches(\"\\\\d+-\\\\d+\\\\.rec\");\n}\n// call Catalog.parseSegmentFilePosition(f) only if isValidSegmentFilename(f)","typeGuard":"boolean isSegmentFile(String name) { return name != null && name.indexOf('-') > 0 && name.endsWith(\".rec\"); }","tryCatchPattern":"try {\n    pos = Catalog.parseSegmentFilePosition(filename);\n} catch (ArchiveException e) {\n    log.warn(\"skipping non-segment file: \" + filename);\n}","preventionTips":["Only enumerate files matching the segment pattern in the archive directory","Never rename or hand-edit recording segment files","Keep the archive directory free of foreign/temp files","Verify Aeron versions match across writers and readers"],"tags":["aeron-archive","filename-parsing","catalog","corruption"],"backgroundTag":"invalid-argument-format","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}