{"record":{"id":"f8e2a3653ecbcdaf","repo":"apache/cassandra","slug":"table-tablename-does-not-exist-in-keyspace-keys","errorCode":null,"errorMessage":"Table {tableName} does not exist in keyspace {keyspace}","messagePattern":"Table (.+?) does not exist in keyspace (.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":5887,"sourceCode":"    {\n        return Keyspace.open(keyspace).getColumnFamilyStores().stream().map(cfs -> cfs.name).collect(Collectors.toList());\n    }\n\n    @Override\n    public void validateAndRepairPeersMetadata()\n    {\n        SystemPeersValidator.validateAndRepair(ClusterMetadata.current());\n    }\n\n    @Override\n    public List<String> mutateSSTableRepairedState(boolean repaired, boolean preview, String keyspace, List<String> tableNames)\n    {\n        Map<String, ColumnFamilyStore> tables =  Keyspace.open(keyspace).getColumnFamilyStores()\n                                                         .stream().collect(Collectors.toMap(c -> c.name, c -> c));\n        for (String tableName : tableNames)\n        {\n            if (!tables.containsKey(tableName))\n                throw new RuntimeException(\"Table \" + tableName + \" does not exist in keyspace \" + keyspace);\n        }\n\n        // only select SSTables that are unrepaired when repaired is true and vice versa\n        Predicate<SSTableReader> predicate = sst -> repaired != sst.isRepaired();\n\n        // mutate SSTables\n        long repairedAt = !repaired ? 0 : currentTimeMillis();\n        List<String> sstablesTouched = new ArrayList<>();\n        for (String tableName : tableNames)\n        {\n            ColumnFamilyStore table = tables.get(tableName);\n            Set<SSTableReader> result = table.runWithCompactionsDisabled(() -> {\n                Set<SSTableReader> sstables = table.getLiveSSTables().stream().filter(predicate).collect(Collectors.toSet());\n                if (!preview)\n                    table.getCompactionStrategyManager().mutateRepaired(sstables, repairedAt, null, false);\n                return sstables;\n            }, predicate, OperationType.ANTICOMPACTION, true, false, true);\n            if (result == null)","sourceCodeStart":5869,"sourceCodeEnd":5905,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L5869-L5905","documentation":"Thrown by StorageService's unrepaired-SSTable listing API when one of the requested table names does not exist in the given keyspace. A plain RuntimeException that validates the tableNames list against the keyspace's live ColumnFamilyStores before mutating any SSTables.","triggerScenarios":"Calling the SSTable repair/anticompaction listing method (e.g. unrepairedSSTables / scrub-style JMX ops) with a tableNames entry absent from Keyspace.open(keyspace).getColumnFamilyStores().","commonSituations":"Typo in a table name in a multi-table list; table dropped mid-operation; using fully qualified names (ks.tbl) where only bare table names are expected.","solutions":["Validate each name against system_schema.tables for the keyspace and correct typos.","Remove entries for tables that no longer exist.","Pass bare table names, not keyspace-qualified names."],"exampleFix":"// before\nList<String> names = Arrays.asList(\"t1\", \"ks.t2\");\nss.unrepairedSSTables(\"ks\", names); // throws for 'ks.t2'\n// after\nList<String> names = Arrays.asList(\"t1\", \"t2\");\nss.unrepairedSSTables(\"ks\", names);","handlingStrategy":"validation","validationCode":"Set<String> existing = Schema.instance.getKeyspaceMetadata(keyspace).tables.stream().map(t -> t.name).collect(Collectors.toSet());\nList<String> invalid = tableNames.stream().filter(n -> !existing.contains(n)).collect(Collectors.toList());\nif (!invalid.isEmpty()) throw new IllegalArgumentException(\"unknown tables: \" + invalid);","typeGuard":null,"tryCatchPattern":"try { ss.unrepairedSSTables(keyspace, tableNames); }\ncatch (RuntimeException e) { if (e.getMessage().contains(\"does not exist in keyspace\")) { /* fix name list */ } throw e; }","preventionTips":["Validate table lists against system_schema.tables first","Pass bare table names, not ks.tbl","Refresh the table list if the schema recently changed"],"tags":["cassandra","table-not-found","sstable","runtime-exception"],"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-14T16:17:12.679Z"}