{"record":{"id":"5083580bbbcb7273","repo":"apache/cassandra","slug":"unknown-keyspace-508358","errorCode":null,"errorMessage":"Unknown keyspace ","messagePattern":"Unknown keyspace ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":2157,"sourceCode":"                    Token token = TokenMap.nextToken(tokenMap.tokens(), range.right.getToken());\n                    rangeToEndpointMap.put(range, metadata.placement(keyspaceMetadata.params.replication)\n                                                  .reads.forRange(token).get());\n                }\n            }\n        }\n        else\n        {\n            // Handling the keyspaces which are not handled by CMS like system keyspace which uses LocalStrategy.\n            Keyspace ks = Keyspace.openIfExists(keyspace);\n            if (ks != null)\n            {\n                AbstractReplicationStrategy strategy = ks.getReplicationStrategy();\n                for (Range<Token> range : ranges)\n                    rangeToEndpointMap.put(range, strategy.calculateNaturalReplicas(range.right, metadata));\n            }\n            else\n            {\n                throw new IllegalArgumentException(\"Unknown keyspace \" + keyspace);\n            }\n        }\n\n        return new EndpointsByRange(rangeToEndpointMap);\n\n    }\n\n    public void beforeChange(InetAddressAndPort endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue)\n    {\n        // no-op\n    }\n\n    /*\n     * Handle the reception of a new particular ApplicationState for a particular endpoint. Note that the value of the\n     * ApplicationState has not necessarily \"changed\" since the last known value, if we already received the same update\n     * from somewhere else.\n     *\n     * onChange only ever sees one ApplicationState piece change at a time (even if many ApplicationState updates were","sourceCodeStart":2139,"sourceCodeEnd":2175,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L2139-L2175","documentation":"Thrown by StorageService's endpoint-range lookup methods when the caller passes a keyspace name that does not exist in the local schema. Cassandra cannot compute natural replicas (range-to-endpoint mapping) without a replication strategy, which only exists for a registered keyspace, so it fails fast with IllegalArgumentException.","triggerScenarios":"Calling describeRing / getRangeToEndpointMap (via JMX nodetool or StorageServiceMBean) with a misspelled or dropped keyspace name; querying before schema is fully distributed to the node; case-sensitive name mismatch ('MyKS' vs 'myks').","commonSituations":"Typo in nodetool -k flag; running a ring command right after CREATE KEYSPACE on a node that has not yet received the schema change; keyspace dropped by another client between listing and lookup; automation scripts caching stale keyspace names.","solutions":["Verify the keyspace exists: run SELECT keyspace_name FROM system_schema.keyspaces; or cqlsh DESCRIBE KEYSPACES","Correct the keyspace name spelling/case passed to the tool or API call","Retry after schema agreement is reached (nodetool describecluster / await schema version convergence) if the keyspace was just created","Recreate the keyspace if it was accidentally dropped"],"exampleFix":"// before\nstorageService.getRangeToEndpointMap(\"UserKeyspace\");\n// after\nif (Schema.instance.getKeyspaceMetadata(\"user_keyspace\") != null)\n    storageService.getRangeToEndpointMap(\"user_keyspace\");","handlingStrategy":"validation","validationCode":"if (Schema.instance.getKeyspaceMetadata(keyspace) == null)\n    throw new IllegalArgumentException(\"Keyspace does not exist: \" + keyspace);\nstorageService.getRangeToEndpointMap(keyspace);","typeGuard":null,"tryCatchPattern":"try { map = ss.getRangeToEndpointMap(ks); } catch (IllegalArgumentException e) { /* unknown keyspace: verify name/schema sync */ }","preventionTips":["Validate keyspace names against system_schema.keyspaces before JMX calls","Use exact lowercase identifiers as stored in schema","Wait for schema agreement after DDL before running ring operations"],"tags":["cassandra","keyspace","schema","invalid-argument"],"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"}