{"record":{"id":"94333bbf91bd8aed","repo":"apache/cassandra","slug":"not-found-in-keyspaces","errorCode":null,"errorMessage":"'{}' not found in keyspaces","messagePattern":"'(.+?)' not found in keyspaces","errorType":"exception","errorClass":"ObjectNotFound","httpStatus":null,"severity":"error","filePath":"pylib/cqlshlib/cqlshmain.py","lineNumber":618,"sourceCode":"            raise IndexNotFound(\"Index {} not found\".format(idxname))\n\n        return ksmeta.indexes[idxname]\n\n    def get_view_meta(self, ksname, viewname):\n        if ksname is None:\n            ksname = self.current_keyspace\n        ksmeta = self.get_keyspace_meta(ksname)\n\n        if viewname not in ksmeta.views:\n            raise MaterializedViewNotFound(\"Materialized view '{}' not found\".format(viewname))\n        return ksmeta.views[viewname]\n\n    def get_object_meta(self, ks, name):\n        if name is None:\n            if ks and ks in self.conn.metadata.keyspaces:\n                return self.conn.metadata.keyspaces[ks]\n            elif self.current_keyspace is None:\n                raise ObjectNotFound(\"'{}' not found in keyspaces\".format(ks))\n            else:\n                name = ks\n                ks = self.current_keyspace\n\n        if ks is None:\n            ks = self.current_keyspace\n\n        ksmeta = self.get_keyspace_meta(ks)\n\n        if name in ksmeta.tables:\n            return ksmeta.tables[name]\n        elif name in ksmeta.indexes:\n            return ksmeta.indexes[name]\n        elif name in ksmeta.views:\n            return ksmeta.views[name]\n\n        raise ObjectNotFound(\"'{}' not found in keyspace '{}'\".format(name, ks))\n","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/pylib/cqlshlib/cqlshmain.py#L600-L636","documentation":"Shell.get_object_meta raises ObjectNotFound when name is None and the given keyspace ks is neither present in conn.metadata.keyspaces nor is there a current session keyspace to fall back on. It signals that the requested keyspace itself cannot be resolved.","triggerScenarios":"get_object_meta(ks, None) where ks is a nonexistent keyspace and self.current_keyspace is None (no USE issued); i.e. asking for an object at keyspace scope with an unresolvable/unknown keyspace and no default.","commonSituations":"DESCRIBE-type operations before any USE while passing a typo'd keyspace name; tab-completion/autocomplete in cqlsh before connecting context is established; scripts that assume a default keyspace exists.","solutions":["Correct the keyspace name (verify with DESCRIBE KEYSPACES).","Issue USE <keyspace> first so current_keyspace provides a fallback.","Refresh schema metadata if the keyspace was created recently.","Create the keyspace with CREATE KEYSPACE if missing."],"exampleFix":"// before\nshell.get_object_meta('sales', None)  # ObjectNotFound, no current keyspace\n// after\nshell.get_object_meta('sales_db', None)  # valid keyspace name","handlingStrategy":"validation","validationCode":"if ks is None:\n    ks = shell.current_keyspace\nif ks is None or ks not in shell.conn.metadata.keyspaces:\n    raise LookupError(f\"Cannot resolve keyspace {ks!r}\")","typeGuard":"def resolvable_keyspace(shell, ks):\n    return ks is not None and ks in shell.conn.metadata.keyspaces","tryCatchPattern":"try:\n    obj = shell.get_object_meta(ks, None)\nexcept ObjectNotFound:\n    obj = None  # surface available keyspaces to the caller","preventionTips":["Issue USE <keyspace> before keyspace-scope lookups.","Validate keyspace names against DESCRIBE KEYSPACES output.","Avoid assuming a default keyspace exists in scripts."],"tags":["cassandra","cqlsh","keyspace","object-lookup","not-found"],"backgroundTag":"entity-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"}