{"record":{"id":"b4e95a4206555c9e","repo":"apache/cassandra","slug":"invalid-sstable-file-name-msgformat","errorCode":null,"errorMessage":"Invalid sstable file ${name}: ${msgFormat}","messagePattern":"Invalid sstable file (.+?): (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/Descriptor.java","lineNumber":467,"sourceCode":"        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    {\n        return version.isCompatible();\n    }\n\n    public Set<Component> discoverComponents()\n    {\n        Set<Component> components = Sets.newHashSetWithExpectedSize(Component.Type.all.size());","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/Descriptor.java#L449-L485","documentation":"invalidSSTable() is Descriptor's central helper that raises IllegalArgumentException with 'Invalid sstable file <name>: <reason>' for every structural validation failure beyond version parsing — e.g. keyspace/table cannot be extracted, wrong sub-directory layout, or bad generation/component fields. Callers include formatFromName, fromFileWithComponent, validateAndExtractInfo, and parentOf.","triggerScenarios":"Constructing a Descriptor from a file or path (Descriptor.fromFilename, fromFileWithComponent, parentOf) where the file is outside the expected per-table subdirectories, or the name cannot yield keyspace/table/gen/component — e.g. running tools against flat (pre-3.0-style) directories.","commonSituations":"Running nodetool/sstable tools in the wrong directory; moving SSTables to a different table directory without the matching table UUID; misconfigured backups restored into wrong locations.","solutions":["Move the SSTable into the correct per-table subdirectory (data/<keyspace>/<table>-<uuid>/) as the error hint about sub-directories suggests","Regenerate the descriptor path via the node/tooling instead of hand-assembling paths","If the file is unrelated to this table, relocate or delete it; verify keyspace/table extraction by matching the directory names"],"exampleFix":"// before\n/var/lib/cassandra/data/ks/ks-t1-00001-Data.db   (flat layout)\n// after\n/var/lib/cassandra/data/ks/t1-<table-uuid>/t1-00001-Data.db","handlingStrategy":"validation","validationCode":"File tableDir = file.getParentFile();\nif (tableDir == null || !tableDir.getName().matches(\".+-[0-9a-fA-F-]{36}\"))\n    throw new IllegalArgumentException(\"SSTable not in a per-table subdirectory: \" + file);","typeGuard":null,"tryCatchPattern":"try { Descriptor d = Descriptor.parentOf(file); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid sstable file\"))\n        // move the file into data/<ks>/<table>-<uuid>/\n}","preventionTips":["Restore backups preserving the data/<keyspace>/<table>-<uuid>/ layout","Use tooling APIs to derive descriptors rather than string paths","Verify directory structure after any manual data movement"],"tags":["sstable","descriptor","file-layout"],"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"}