{"record":{"id":"4841db382d63a633","repo":"apache/cassandra","slug":"provided-filename-new-file-directory-name","errorCode":null,"errorMessage":"Provided filename \" + new File(directory, name) + \" is not valid for a data segment file","messagePattern":"Provided filename \" \\+ new File\\(directory, name\\) \\+ \" is not valid for a data segment file","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/journal/Descriptor.java","lineNumber":102,"sourceCode":"    Descriptor(File directory, long timestamp, int generation, int journalVersion, int userVersion)\n    {\n        this.directory = directory;\n        this.timestamp = timestamp;\n        this.generation = generation;\n        this.journalVersion = journalVersion;\n        this.userVersion = userVersion;\n    }\n\n    static Descriptor create(File directory, long timestamp, int userVersion)\n    {\n        return new Descriptor(directory, timestamp, 1, CURRENT_JOURNAL_VERSION, userVersion);\n    }\n\n    static Descriptor fromName(File directory, String name)\n    {\n        Matcher matcher = DATA_FILE_PATTERN.matcher(name);\n        if (!matcher.matches())\n            throw new IllegalArgumentException(\"Provided filename \" + new File(directory, name) + \" is not valid for a data segment file\");\n\n        long timestamp = Long.parseLong(matcher.group(1));\n        int generation = Integer.parseInt(matcher.group(2));\n        int journalVersion = Integer.parseInt(matcher.group(3));\n        int userVersion = Integer.parseInt(matcher.group(4));\n\n        return new Descriptor(directory, timestamp, generation, journalVersion, userVersion);\n    }\n\n    public static Descriptor fromFile(File file)\n    {\n        return fromName(file.parent(), file.name());\n    }\n\n    File fileFor(Component component)\n    {\n        return new File(directory, formatFileName(component));\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/journal/Descriptor.java#L84-L120","documentation":"Descriptor.fromName parses journal segment file names matching the expected pattern (timestamp, generation, versions). If the filename doesn't match, it throws IllegalArgumentException. This protects against unrecognized or foreign files in the journal directory being treated as segments.","triggerScenarios":"Listing or loading a journal directory containing files that don't match the segment naming pattern, e.g. temp files, editor backups, hand-copied files with wrong names, or files from incompatible versions.","commonSituations":"Manual file manipulation in the data directory; interrupted writes leaving partial names; version-downgrade/upgrade where naming conventions differ; restore from backup missing rename steps.","solutions":["Remove or move non-segment files out of the journal directory","Verify the file name matches the expected pattern (correct extensions/fields for the journal version)","Restore files with their original names from a proper backup/snapshot","Check you're running a compatible Cassandra version for the data directory"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!name.matches(\"^\\\\d+_\\\\d+_\\\\d+_\\\\d+\\\\.crc|DATA_PATTERN$\")) skipFile(name); // validate before passing to fromName","typeGuard":"boolean isSegmentFile(String name) { return DATA_FILE_PATTERN.matcher(name).matches(); }","tryCatchPattern":"try { Descriptor.fromName(dir, name); } catch (IllegalArgumentException e) { log.warn(\"skipping non-segment file\", e); }","preventionTips":["Don't place arbitrary files in the journal directory","Restore from backups preserving original filenames","Keep Cassandra versions consistent with on-disk data","Filter directory listings with the descriptor pattern before opening"],"tags":["filename","parsing","illegal-argument"],"backgroundTag":"invalid-identifier-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}