{"record":{"id":"ea4913fb0174c70c","repo":"apache/cassandra","slug":"cannot-parse-the-version-of-the-file","errorCode":null,"errorMessage":"Cannot parse the version of the file: ","messagePattern":"Cannot parse the version of the file: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/commitlog/CommitLogDescriptor.java","lineNumber":211,"sourceCode":"\n    public static CommitLogDescriptor fromFileName(String name)\n    {\n        Matcher matcher = extactFromFileName(name);\n        long id = Long.parseLong(matcher.group(3).split(SEPARATOR)[1]);\n        return new CommitLogDescriptor(Integer.parseInt(matcher.group(2)), id, null, new EncryptionContext());\n    }\n\n    public static long idFromFileName(String name)\n    {\n        Matcher matcher = extactFromFileName(name);\n        return Long.parseLong(matcher.group(3).split(SEPARATOR)[1]);\n    }\n\n    private static Matcher extactFromFileName(String name)\n    {\n        Matcher matcher = COMMIT_LOG_FILE_PATTERN.matcher(name);\n        if (!matcher.matches())\n            throw new RuntimeException(\"Cannot parse the version of the file: \" + name);\n\n        if (matcher.group(3) == null)\n            throw new UnsupportedOperationException(\"Commitlog segment is too old to open; upgrade to 1.2.5+ first\");\n\n        return matcher;\n    }\n\n    public int getMessagingVersion()\n    {\n        switch (version)\n        {\n            case VERSION_30:\n                return MessagingService.VERSION_30;\n            case VERSION_40:\n                return MessagingService.VERSION_40;\n            case VERSION_50:\n                return MessagingService.VERSION_50;\n            case VERSION_60:","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/commitlog/CommitLogDescriptor.java#L193-L229","documentation":"CommitLogDescriptor.extactFromFileName matches a segment file name against COMMIT_LOG_FILE_PATTERN. If the name does not match the expected 'CommitLog<version>-<id>.log' pattern, the descriptor cannot be derived from the file name, and a RuntimeException 'Cannot parse the version of the file: <name>' is thrown.","triggerScenarios":"Calling CommitLogDescriptor.fromFileName (or code paths that derive descriptors from names, including archive restore) with a file name that does not match the commit log naming pattern — wrong prefix, missing separator, extra suffixes.","commonSituations":"Renamed or hand-edited commit log files, restore directory containing non-commitlog files, truncated names from failed copies, or files like 'CommitLog-4-123.log' produced by different tooling/older layouts.","solutions":["Rename the file to the canonical pattern CommitLog<version>-<id>.log (e.g. CommitLog-6-1700000000000.log) if it is a genuine segment.","Remove non-commitlog files (backups, temp copies, editor artifacts) from the commitlog/restore directory.","Verify the restoreDirectories/commitlog location in configuration points only at valid Cassandra commit log segments.","Re-copy the segment from a healthy backup if the name was truncated during transfer."],"exampleFix":"// before\nmv CommitLog.log /var/lib/cassandra/commitlog/   // unparseable -> RuntimeException\n// after\nmv CommitLog.log /var/lib/cassandra/commitlog/CommitLog-6-1690000000000.log","handlingStrategy":"validation","validationCode":"Pattern P = Pattern.compile(\"CommitLog(\\\\d+)-(\\\\d+)(\\\\d*)\\\\.log\");\nif (!P.matcher(file.getName()).matches())\n    logger.warn(\"{} is not a valid commit log file name\", file.getName());","typeGuard":null,"tryCatchPattern":"try { CommitLogDescriptor.fromFileName(name); } catch (RuntimeException e) { logger.error(\"Bad segment name: {}\", e.getMessage()); }","preventionTips":["Never rename commit log segments by hand","Keep backup/restore directories free of non-commitlog files","Verify file integrity (sizes, names) after copying archives"],"tags":["commitlog","filename","parse"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}