{"record":{"id":"d7dc07d117ba9475","repo":"apache/cassandra","slug":"cannot-perform-any-operations-against-virtual-keys","errorCode":null,"errorMessage":"Cannot perform any operations against virtual keyspace \" + keyspaceName","messagePattern":"Cannot perform any operations against virtual keyspace \" \\+ keyspaceName","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/Keyspace.java","lineNumber":230,"sourceCode":"        if (cfs == null)\n            throw new IllegalArgumentException(String.format(\"Unknown CF %s %s\", id, columnFamilyStores));\n        return cfs;\n    }\n\n    public ColumnFamilyStore getIfExists(TableId id)\n    {\n        return columnFamilyStores.get(id);\n    }\n\n    public boolean hasColumnFamilyStore(TableId id)\n    {\n        return columnFamilyStores.containsKey(id);\n    }\n\n    public static void verifyKeyspaceIsValid(String keyspaceName)\n    {\n        if (null != VirtualKeyspaceRegistry.instance.getKeyspaceNullable(keyspaceName))\n            throw new IllegalArgumentException(\"Cannot perform any operations against virtual keyspace \" + keyspaceName);\n\n        if (!Schema.instance.getKeyspaces().contains(keyspaceName))\n            throw new IllegalArgumentException(\"Keyspace \" + keyspaceName + \" does not exist\");\n    }\n\n    public static Keyspace getValidKeyspace(String keyspaceName)\n    {\n        verifyKeyspaceIsValid(keyspaceName);\n        return Keyspace.open(keyspaceName);\n    }\n\n    /**\n     * @return A list of open SSTableReaders\n     */\n    public List<SSTableReader> getAllSSTables(SSTableSet sstableSet)\n    {\n        List<SSTableReader> list = new ArrayList<>(columnFamilyStores.size());\n        for (ColumnFamilyStore cfStore : columnFamilyStores.values())","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/Keyspace.java#L212-L248","documentation":"Keyspace.verifyKeyspaceIsValid(keyspaceName) rejects names registered in the VirtualKeyspaceRegistry with IllegalArgumentException 'Cannot perform any operations against virtual keyspace <name>'. Virtual keyspaces (system_views, system_virtual_schema) are in-memory, non-persisted views that cannot accept writes or DDL, so operations targeting them are refused.","triggerScenarios":"Calling getValidKeyspace/verifyKeyspaceIsValid with 'system_views' or another virtual keyspace before operations like writes, schema changes, or snapshots; tooling that enumerates all keyspaces (including virtual) and then performs real operations on each.","commonSituations":"Scripts iterating over `DESCRIBE KEYSPACES` output that includes virtual keyspaces; monitoring tooling querying virtual tables but attempting admin operations; mistakenly treating virtual keyspace tables as regular tables for backup/restore.","solutions":["Skip virtual keyspaces: filter out names present in VirtualKeyspaceRegistry (system_views, system_virtual_schema) before performing operations.","Query the virtual tables only via SELECT (CQL queries are read-only there); never target them with writes/DDL/snapshots.","Use Schema.instance.getKeyspaces() excluding VirtualKeyspaceRegistry entries when enumerating keyspaces for batch operations."],"exampleFix":"// before\nKeyspace.open(ksName); // fails for system_views\n// after\nif (VirtualKeyspaceRegistry.instance.getKeyspaceNullable(ksName) == null)\n    Keyspace.open(ksName);","handlingStrategy":"validation","validationCode":"if (VirtualKeyspaceRegistry.instance.getKeyspaceNullable(ksName) != null)\n    throw new IllegalArgumentException(ksName + \" is a virtual keyspace; read-only via CQL SELECT\");\n","typeGuard":"static boolean isVirtualKeyspace(String ks) {\n    return VirtualKeyspaceRegistry.instance.getKeyspaceNullable(ks) != null;\n}\n","tryCatchPattern":"try {\n    Keyspace.getValidKeyspace(ksName);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Cannot perform any operations against virtual keyspace\"))\n        return; // skip virtual keyspaces in batch jobs\n    throw e;\n}\n","preventionTips":["Filter out system_views and system_virtual_schema when iterating keyspaces for admin operations.","Treat virtual-keyspace tables as read-only monitoring endpoints only.","Use Schema.instance.getKeyspaces() minus VirtualKeyspaceRegistry entries for operation lists."],"tags":["virtual-keyspace","invalid-argument","read-only"],"backgroundTag":"unsupported-operation","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"}