{"record":{"id":"3da193b83020c27c","repo":"apache/cassandra","slug":"unknown-keyspace-keyspacename-3da193","errorCode":null,"errorMessage":"Unknown keyspace '{keyspaceName}'","messagePattern":"Unknown keyspace '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":3459,"sourceCode":"        return Replicas.stringify(replicas, true);\n    }\n\n    public EndpointsForToken getNaturalReplicasForToken(String keyspaceName, String cf, String key)\n    {\n        return getNaturalReplicasForToken(keyspaceName, partitionKeyToBytes(keyspaceName, cf, key));\n    }\n\n    public DecoratedKey getKeyFromPartition(String keyspaceName, String table, String partitionKey)\n    {\n        IPartitioner partitioner = Keyspace.open(keyspaceName).getColumnFamilyStore(table).getPartitioner();\n        return partitioner.decorateKey(partitionKeyToBytes(keyspaceName, table, partitionKey));\n    }\n\n    private static ByteBuffer partitionKeyToBytes(String keyspaceName, String cf, String key)\n    {\n        KeyspaceMetadata ksMetaData = Schema.instance.getKeyspaceMetadata(keyspaceName);\n        if (ksMetaData == null)\n            throw new IllegalArgumentException(\"Unknown keyspace '\" + keyspaceName + \"'\");\n\n        TableMetadata metadata = ksMetaData.getTableOrViewNullable(cf);\n        if (metadata == null)\n            throw new IllegalArgumentException(\"Unknown table '\" + cf + \"' in keyspace '\" + keyspaceName + \"'\");\n\n        return metadata.partitionKeyType.fromString(key);\n    }\n\n    @Override\n    public String getToken(String keyspaceName, String table, String key)\n    {\n        ColumnFamilyStore cfs = Keyspace.open(keyspaceName).getColumnFamilyStore(table);\n        return cfs.getPartitioner().getToken(partitionKeyToBytes(keyspaceName, table, key)).toString();\n    }\n\n    public EndpointsForToken getNaturalReplicasForToken(String keyspaceName, ByteBuffer key)\n    {\n        ClusterMetadata metadata = ClusterMetadata.current();","sourceCodeStart":3441,"sourceCodeEnd":3477,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L3441-L3477","documentation":"partitionKeyToBytes (used by token/sample-key JMX operations like getToken) resolves the keyspace metadata first; if Schema.instance has no such keyspace it throws IllegalArgumentException. The key string must be parsed with the table's partition key type, which requires valid keyspace/table metadata.","triggerScenarios":"Calling StorageServiceMBean.getToken / getSamplePartitionKey paths with a nonexistent or misspelled keyspace name; case mismatch on keyspace identifiers.","commonSituations":"Typo in scripts driving nodetool gettoken; running the call on a node before schema sync; referencing a keyspace dropped concurrently.","solutions":["Confirm the keyspace exists via cqlsh DESCRIBE KEYSPACES or system_schema.keyspaces","Correct the keyspace name spelling and case","Retry after schema agreement if the keyspace was recently created"],"exampleFix":"// before\nstorageService.getToken(\"Ks\", \"tbl\", \"key1\");\n// after\nif (Schema.instance.getKeyspaceMetadata(\"ks\") != null)\n    storageService.getToken(\"ks\", \"tbl\", \"key1\");","handlingStrategy":"validation","validationCode":"if (Schema.instance.getKeyspaceMetadata(keyspaceName) == null)\n    throw new IllegalArgumentException(\"Keyspace does not exist: \" + keyspaceName);","typeGuard":null,"tryCatchPattern":"try { ss.getToken(ks, table, key); } catch (IllegalArgumentException e) { /* check keyspace name */ }","preventionTips":["Resolve keyspace names from cqlsh DESCRIBE or system_schema before token lookups","Use lowercase unquoted identifiers","Ensure schema is synced on the target node"],"tags":["cassandra","schema","keyspace","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"}