apache/cassandra · error · ObjectNotFound
'{}' not found in keyspaces
Error message
'{}' not found in keyspaces What it means
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.
Source
Thrown at pylib/cqlshlib/cqlshmain.py:618
raise IndexNotFound("Index {} not found".format(idxname))
return ksmeta.indexes[idxname]
def get_view_meta(self, ksname, viewname):
if ksname is None:
ksname = self.current_keyspace
ksmeta = self.get_keyspace_meta(ksname)
if viewname not in ksmeta.views:
raise MaterializedViewNotFound("Materialized view '{}' not found".format(viewname))
return ksmeta.views[viewname]
def get_object_meta(self, ks, name):
if name is None:
if ks and ks in self.conn.metadata.keyspaces:
return self.conn.metadata.keyspaces[ks]
elif self.current_keyspace is None:
raise ObjectNotFound("'{}' not found in keyspaces".format(ks))
else:
name = ks
ks = self.current_keyspace
if ks is None:
ks = self.current_keyspace
ksmeta = self.get_keyspace_meta(ks)
if name in ksmeta.tables:
return ksmeta.tables[name]
elif name in ksmeta.indexes:
return ksmeta.indexes[name]
elif name in ksmeta.views:
return ksmeta.views[name]
raise ObjectNotFound("'{}' not found in keyspace '{}'".format(name, ks))
View on GitHub (pinned to 88fd0f6a0e)
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.
Example fix
// before
shell.get_object_meta('sales', None) # ObjectNotFound, no current keyspace
// after
shell.get_object_meta('sales_db', None) # valid keyspace name Defensive patterns
Strategy: validation
Validate before calling
if ks is None:
ks = shell.current_keyspace
if ks is None or ks not in shell.conn.metadata.keyspaces:
raise LookupError(f"Cannot resolve keyspace {ks!r}") Type guard
def resolvable_keyspace(shell, ks):
return ks is not None and ks in shell.conn.metadata.keyspaces Try / catch
try:
obj = shell.get_object_meta(ks, None)
except ObjectNotFound:
obj = None # surface available keyspaces to the caller Prevention
- Issue USE <keyspace> before keyspace-scope lookups.
- Validate keyspace names against DESCRIBE KEYSPACES output.
- Avoid assuming a default keyspace exists in scripts.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Keyspace %r not found.
- '{}' not found in keyspace '{}'
- Keyspace %s doesn't exist
- User type {!r} not found
- Column family {} not found
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/94333bbf91bd8aed.
Report an issue: GitHub.