apache/cassandra · error · ObjectNotFound

'{}' not found in keyspace '{}'

Error message

'{}' not found in keyspace '{}'

What it means

Shell.get_object_meta falls through to ObjectNotFound when the given name matches no table, index, or view in the resolved keyspace (it already checked keyspaces first). This is the generic 'object does not exist in this keyspace' terminal error of the lookup.

Source

Thrown at pylib/cqlshlib/cqlshmain.py:635

            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))

    def get_trigger_names(self, ksname=None):
        if ksname is None:
            ksname = self.current_keyspace

        return [trigger.name
                for table in list(self.get_keyspace_meta(ksname).tables.values())
                for trigger in list(table.triggers.values())]

    def reset_statement(self):
        self.reset_prompt()
        self.statement.truncate(0)
        self.statement.seek(0)
        self.empty_lines = 0

    def reset_prompt(self):
        if self.current_keyspace is None:
            self.set_prompt(self.default_prompt, True)

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Verify the exact object name with DESCRIBE KEYSPACE <ks>.
  2. Prefix the object with its keyspace (ks.object) or USE the correct keyspace first.
  3. Refresh schema metadata / reconnect if the object was just created.
  4. Check name casing — unquoted identifiers are lowercased in CQL.

Example fix

// before
shell.get_object_meta('ks', 'User')  # ObjectNotFound (case-sensitive after quoting)
// after
shell.get_object_meta('ks', 'user')  # unquoted identifiers are lowercase
Defensive patterns

Strategy: try-catch

Validate before calling

ksmeta = shell.get_keyspace_meta(ks)
found = name in ksmeta.tables or name in ksmeta.indexes or name in ksmeta.views
if not found:
    raise LookupError(f"{name!r} not a table/index/view in {ks}")

Type guard

def object_exists(shell, ks, name):
    m = shell.get_keyspace_meta(ks)
    return name in m.tables or name in m.indexes or name in m.views

Try / catch

try:
    obj = shell.get_object_meta(ks, name)
except ObjectNotFound:
    obj = None  # list valid objects for the user

Prevention

When it happens

Trigger: get_object_meta(ks, name) where name is not a key in ksmeta.tables, ksmeta.indexes, nor ksmeta.views (and not the keyspace itself). E.g. DESCRIBE <badname>, or programmatic resolution of an identifier before parsing.

Common situations: Typos in table/index/view names; referring to a table without the keyspace while the wrong keyspace is in scope; object dropped by another client; identifier case-sensitivity problems.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/807d8a4691d98e8d. Report an issue: GitHub.