{"record":{"id":"77345f0b922f6b7e","repo":"apache/cassandra","slug":"you-must-supply-a-keyspace-name","errorCode":null,"errorMessage":"You must supply a keyspace name","messagePattern":"You must supply a keyspace name","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/snapshot/TakeSnapshotTask.java","lineNumber":210,"sourceCode":"        snapshotToCreate.complete();\n    }\n\n    private Set<ColumnFamilyStore> parseEntitiesForSnapshot(String... entities)\n    {\n        Set<ColumnFamilyStore> entitiesForSnapshot = new HashSet<>();\n\n        if (entities != null && entities.length > 0 && entities[0].contains(\".\"))\n        {\n            for (String entity : entities)\n            {\n                String[] splitted = StringUtils.split(entity, '.');\n                if (splitted.length == 2)\n                {\n                    String keyspaceName = splitted[0];\n                    String tableName = splitted[1];\n\n                    if (keyspaceName == null)\n                        throw new RuntimeException(\"You must supply a keyspace name\");\n                    if (tableName == null)\n                        throw new RuntimeException(\"You must supply a table name\");\n\n                    Keyspace validKeyspace = Keyspace.getValidKeyspace(keyspaceName);\n                    ColumnFamilyStore existingTable = validKeyspace.getColumnFamilyStore(tableName);\n\n                    entitiesForSnapshot.add(existingTable);\n                }\n                // special case for index which we can not normally create a snapshot for\n                // but a snapshot is apparently taken before a secondary index is scrubbed,\n                // so we preserve this behavior\n                else if (splitted.length == 3)\n                {\n                    String keyspaceName = splitted[0];\n                    String tableName = splitted[1];\n\n                    Keyspace validKeyspace = Keyspace.getValidKeyspace(keyspaceName);\n                    ColumnFamilyStore existingTable = validKeyspace.getColumnFamilyStore(tableName);","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/snapshot/TakeSnapshotTask.java#L192-L228","documentation":"parseEntitiesForSnapshot parses 'keyspace.table' entity strings and throws RuntimeException('You must supply a keyspace name') when the keyspace part is null. In practice the split already guaranteed two tokens, so this guards a null/empty keyspace name supplied to the snapshot entity parser before Keyspace.getValidKeyspace is called. Note that a present-but-missing keyspace is instead rejected later by getValidKeyspace.","triggerScenarios":"Calling the snapshot API/StorageService.takeSnapshot with entity strings lacking a keyspace portion (null keyspace token reaching this branch), e.g. passing malformed entity arguments programmatically via JMX.","commonSituations":"JMX/console invocations constructing entity strings manually instead of via nodetool parsing; scripts building 'keyspace.table' pairs where the keyspace variable is unset/null.","solutions":["Supply entities in 'keyspace.table' form with a non-empty keyspace name.","Verify the calling script's keyspace variable is set and non-empty before invoking the snapshot.","Prefer nodetool snapshot CLI parsing, which validates entity format before reaching this code."],"exampleFix":"// before\nString entity = \".users\"; // empty keyspace part\n// after\nString entity = \"keyspace1.users\";","handlingStrategy":"validation","validationCode":"if (entity == null || entity.indexOf('.') <= 0)\n    throw new IllegalArgumentException(\"Entity must be keyspace.table: \" + entity);\nString ks = entity.substring(0, entity.indexOf('.'));\nif (ks.isEmpty()) throw new IllegalArgumentException(\"Empty keyspace in entity \" + entity);","typeGuard":null,"tryCatchPattern":"try { takeSnapshot(entities); } catch (RuntimeException e) { if (e.getMessage().equals(\"You must supply a keyspace name\")) throw new IllegalArgumentException(\"Malformed entity: \" + entities, e); throw e; }","preventionTips":["Always build entities as 'keyspace.table' from two non-null variables","Validate entity format before JMX calls","Prefer nodetool CLI parsing over hand-built strings"],"tags":["snapshot","keyspace","argument-validation"],"backgroundTag":"missing-required-argument","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"}