{"record":{"id":"6df9d55d2cc5cb55","repo":"apache/cassandra","slug":"unknown-keyspace-6df9d5","errorCode":null,"errorMessage":"Unknown keyspace: ","messagePattern":"Unknown keyspace: ","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java","lineNumber":643,"sourceCode":"        }\n\n        public boolean isKeyspaceIncluded(String keyspace)\n        {\n            // supplying empty params list is treated as wanting to display all keyspaces and tables\n            if (filterList.isEmpty())\n                return !ignoreMode;\n\n            // Note that if there is any table for the keyspace, we want to include the keyspace irregarding\n            // of the ignoreMode, since the ignoreMode then apply to the table inside the keyspace but the\n            // keyspace itself is not ignored\n            return filter.get(keyspace) != null || ignoreMode;\n        }\n\n        public void verifyKeyspaces(Collection<String> keyspaces)\n        {\n            for (String ks : verifier.keySet())\n                if (!keyspaces.contains(ks))\n                    throw new IllegalArgumentException(\"Unknown keyspace: \" + ks);\n        }\n\n        public void verifyTables()\n        {\n            for (String ks : filter.keySet())\n                if (!verifier.get(ks).isEmpty())\n                    throw new IllegalArgumentException(\"Unknown tables: \" + verifier.get(ks) + \" in keyspace: \" + ks);\n        }\n    }\n}\n","sourceCodeStart":625,"sourceCodeEnd":654,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java#L625-L654","documentation":"TableStatsHolder's OptionFilter.verifyKeyspaces validates that every keyspace supplied via nodetool tablestats options actually exists in the cluster. If a user passes a keyspace name that the verifier did not see among live keyspaces, it throws IllegalArgumentException with the offending name. This is a fail-fast input validation for the nodetool CLI.","triggerScenarios":"Running `nodetool tablestats <ks>` (or tablehistograms/cfstats equivalents) with a keyspace name that does not exist, is misspelled, or differs in case from the actual keyspace.","commonSituations":"Typo in keyspace name; assuming case-insensitive matching (Cassandra keyspaces are case-sensitive unless quoted); keyspace dropped between listing and stats collection; environment mix-ups (dev vs prod keyspaces).","solutions":["Run `nodetool describecluster` or query system_schema.keyspaces to list valid keyspace names and use the exact spelling","Re-run the nodetool command with the corrected, case-matched keyspace name","Omit the keyspace argument to collect stats for all keyspaces"],"exampleFix":"// before\nnodetool tablestats MyKeyspace\n// after\nnodetool tablestats my_keyspace   // exact, case-sensitive name from system_schema.keyspaces","handlingStrategy":"validation","validationCode":"Set<String> existing = session.execute(\"SELECT keyspace_name FROM system_schema.keyspaces\").all().stream().map(r -> r.getString(0)).collect(Collectors.toSet());\nif (!existing.contains(ks)) throw new IllegalArgumentException(\"Unknown keyspace: \" + ks);","typeGuard":null,"tryCatchPattern":"try { runNodetool(args); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unknown keyspace:\")) { /* prompt for valid keyspace or list system_schema.keyspaces */ } else throw e; }","preventionTips":["Always list keyspaces from system_schema.keyspaces before filtering","Remember keyspace names are case-sensitive","Script tab-completion against live cluster metadata"],"tags":["cassandra","nodetool","validation"],"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-17T15:17:12.973Z"}