{"record":{"id":"a701c4d9f7ebd415","repo":"apache/cassandra","slug":"keyspace-s-does-not-exist-a701c4","errorCode":null,"errorMessage":"Keyspace [%s] does not exist.","messagePattern":"Keyspace \\[(.+?)\\] does not exist\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/CommandUtils.java","lineNumber":183,"sourceCode":"            if (defaultKeyspaceSet == KeyspaceSet.NON_LOCAL_STRATEGY)\n                keyspaces.addAll(keyspaces = nodeProbe.getNonLocalStrategyKeyspaces());\n            else if (defaultKeyspaceSet == KeyspaceSet.NON_SYSTEM)\n                keyspaces.addAll(keyspaces = nodeProbe.getNonSystemKeyspaces());\n            else if (defaultKeyspaceSet == KeyspaceSet.ACCORD_MANAGED)\n                keyspaces.addAll(nodeProbe.getAccordManagedKeyspaces());\n\n            else\n                keyspaces.addAll(nodeProbe.getKeyspaces());\n        }\n        else\n        {\n            keyspaces.add(cmdArgs.get(0));\n        }\n\n        for (String keyspace : keyspaces)\n        {\n            if (!nodeProbe.getKeyspaces().contains(keyspace))\n                throw new IllegalArgumentException(\"Keyspace [\" + keyspace + \"] does not exist.\");\n        }\n\n        return Collections.unmodifiableList(keyspaces);\n    }\n\n    /**\n     * Parses the optional table names from the command arguments for nodetool commands.\n     * <p>\n     * The nodetool commands can operate on either all tables within a keyspace, or on a specific\n     * subset of tables. This method extracts the table names from the provided cli arguments, assuming\n     * the first argument is the keyspace name and any subsequent arguments are table names.\n     * <p>\n     * If no table names are provided (e.g. only the keyspace is specified), this method returns\n     * an empty array, which signals to the MBeans that the operation should apply to all tables\n     * in the keyspace. This approach provides flexibility to target either all tables or specific\n     * tables as needed.\n     *\n     * @param cmdArgs the list of command arguments, where the first argument is typically the","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/CommandUtils.java#L165-L201","documentation":"parseOptionalKeyspace validates every keyspace supplied on the nodetool command line against the live list of keyspaces returned by NodeProbe.getKeyspaces() via JMX. If a name is not present, it throws IllegalArgumentException so the command fails fast instead of issuing a remote call that would silently do nothing or error later.","triggerScenarios":"Typing a misspelled or dropped keyspace name (including case mismatch, since comparison is case-sensitive) into any nodetool command that takes an optional keyspace: compact, cleanup, repair, flush, scrub, etc.","commonSituations":"Keyspace was dropped or never created; typo or wrong capitalization; connected to the wrong cluster/datacenter that lacks the keyspace; quoting issues splitting the name.","solutions":["Run `nodetool describecluster` / cqlsh `DESCRIBE KEYSPACES` to list valid keyspaces and correct the name.","Check case sensitivity: keyspace names are case-sensitive unless quoted at creation.","Verify you are connecting to the intended cluster/node.","Create the keyspace if it genuinely does not exist yet."],"exampleFix":"// before\nnodetool compact UserKeyspace\n// after\nnodetool compact userkeyspace  # matches actual case-sensitive keyspace name","handlingStrategy":"validation","validationCode":"List<String> existing = probe.getKeyspaces();\nList<String> requested = List.of(\"my_ks\");\nif (!existing.containsAll(requested))\n    throw new IllegalArgumentException(\"Unknown keyspace(s): \" + requested.stream().filter(k -> !existing.contains(k)).toList());","typeGuard":null,"tryCatchPattern":"try { keyspaces = CommandUtils.parseOptionalKeyspace(args, probe); }\ncatch (IllegalArgumentException e) { System.err.println(e.getMessage() + \" — run 'DESCRIBE KEYSPACES' in cqlsh\"); System.exit(2); }","preventionTips":["Validate keyspace names against cqlsh DESCRIBE KEYSPACES before scripting.","Remember keyspace names are case-sensitive unless quoted at creation.","Use consistent naming in automation to avoid case drift.","Confirm which cluster nodetool is connected to before passing keyspaces."],"tags":["nodetool","keyspace","validation","cli"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}