{"record":{"id":"0b4d45c7b76ac94f","repo":"apache/cassandra","slug":"invalid-sstable-file-s-cannot-extract-keyspace-a","errorCode":null,"errorMessage":"Invalid sstable file %s: cannot extract keyspace and table name; make sure the sstable is in the proper sub-directories","messagePattern":"Invalid sstable file (.+?): cannot extract keyspace and table name; make sure the sstable is in the proper sub-directories","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/Descriptor.java","lineNumber":461,"sourceCode":"    private static class SSTableInfo\n    {\n        final Version version;\n        final SSTableId id;\n        final Component component;\n\n        SSTableInfo(Version version, SSTableId id, Component component)\n        {\n            this.version = version;\n            this.id = id;\n            this.component = component;\n        }\n    }\n\n    private static File parentOf(String name, File file)\n    {\n        File parent = file.parent();\n        if (parent == null)\n            throw invalidSSTable(name, \"cannot extract keyspace and table name; make sure the sstable is in the proper sub-directories\");\n        return parent;\n    }\n\n    private static IllegalArgumentException invalidSSTable(String name, String msgFormat, Object... parameters)\n    {\n        throw new IllegalArgumentException(String.format(\"Invalid sstable file \" + name + \": \" + msgFormat, parameters));\n    }\n\n    public IMetadataSerializer getMetadataSerializer()\n    {\n        return new MetadataSerializer();\n    }\n\n    /**\n     * @return true if the current Cassandra version can read the given sstable version\n     */\n    public boolean isCompatible()\n    {","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/Descriptor.java#L443-L479","documentation":"Descriptor.fromFileWithComponent requires sstable data files to live under a directory hierarchy that encodes the keyspace and table name (…/<keyspace>/<table>-<uuid>/…). If the file has no parent directory, the keyspace/table cannot be derived, so Cassandra rejects the file with this IllegalArgumentException.","triggerScenarios":"Calling Descriptor.fromFileWithComponent (or sstable tools that use it) on a file placed at the filesystem root or otherwise lacking a parent directory from which keyspace/table can be parsed.","commonSituations":"Manually copying an sstable out of its table directory (e.g. to / or a flat temp dir) and then running sstable metadata/tools on it; scripted bulk loading that flattens the data directory structure.","solutions":["Place the sstable back under its proper <data_dir>/<keyspace>/<table>-<id>/ directory before using it","Use sstable tooling that accepts explicit keyspace/table arguments instead of path inference, or restore via a snapshot/backup that preserves directory structure","Re-run the tool from the original data directory rather than a moved copy"],"exampleFix":"// before\njava -cp cassandra.jar …SSTableMetadataViewer /mc-1-big-Data.db\n// after\njava -cp cassandra.jar …SSTableMetadataViewer /var/lib/cassandra/data/ks/tbl-abc123/mc-1-big-Data.db","handlingStrategy":"validation","validationCode":"Path p = Paths.get(sstableFile);\nif (p.getParent() == null || p.getNameCount() < 3)\n    throw new IllegalArgumentException(\"SSTable must live under <keyspace>/<table-uuid>/ directories: \" + p);","typeGuard":"static boolean hasValidSstableLayout(File f) { return f != null && f.parent() != null && f.parent().parent() != null; }","tryCatchPattern":"try {\n    Descriptor d = Descriptor.fromFileWithComponent(file);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"cannot extract keyspace and table name\")) {\n        // move file into proper <keyspace>/<table-id>/ layout and retry\n    } else throw e;\n}","preventionTips":["Never flatten the Cassandra data directory layout when copying sstables for tooling","Preserve <data_dir>/<keyspace>/<table-uuid>/ structure in backups and restores","Run sstable tools from the original data directory location, not a relocated single file","Keep sstables out of filesystem root paths in scripts"],"tags":["sstable","filesystem","path"],"backgroundTag":"file-not-found","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"}