apache/cassandra · error · IllegalArgumentException
Keyspace [%s] does not exist.
Error message
Keyspace [%s] does not exist.
What it means
parseOptionalKeyspace validates every keyspace supplied on the nodetool command line against the live list of keyspaces returned by NodeProbe.getKeyspaces() via JMX. If a name is not present, it throws IllegalArgumentException so the command fails fast instead of issuing a remote call that would silently do nothing or error later.
Source
Thrown at src/java/org/apache/cassandra/tools/nodetool/CommandUtils.java:183
if (defaultKeyspaceSet == KeyspaceSet.NON_LOCAL_STRATEGY)
keyspaces.addAll(keyspaces = nodeProbe.getNonLocalStrategyKeyspaces());
else if (defaultKeyspaceSet == KeyspaceSet.NON_SYSTEM)
keyspaces.addAll(keyspaces = nodeProbe.getNonSystemKeyspaces());
else if (defaultKeyspaceSet == KeyspaceSet.ACCORD_MANAGED)
keyspaces.addAll(nodeProbe.getAccordManagedKeyspaces());
else
keyspaces.addAll(nodeProbe.getKeyspaces());
}
else
{
keyspaces.add(cmdArgs.get(0));
}
for (String keyspace : keyspaces)
{
if (!nodeProbe.getKeyspaces().contains(keyspace))
throw new IllegalArgumentException("Keyspace [" + keyspace + "] does not exist.");
}
return Collections.unmodifiableList(keyspaces);
}
/**
* Parses the optional table names from the command arguments for nodetool commands.
* <p>
* The nodetool commands can operate on either all tables within a keyspace, or on a specific
* subset of tables. This method extracts the table names from the provided cli arguments, assuming
* the first argument is the keyspace name and any subsequent arguments are table names.
* <p>
* If no table names are provided (e.g. only the keyspace is specified), this method returns
* an empty array, which signals to the MBeans that the operation should apply to all tables
* in the keyspace. This approach provides flexibility to target either all tables or specific
* tables as needed.
*
* @param cmdArgs the list of command arguments, where the first argument is typically theView on GitHub (pinned to 88fd0f6a0e)
Solutions
- Run `nodetool describecluster` / cqlsh `DESCRIBE KEYSPACES` to list valid keyspaces and correct the name.
- Check case sensitivity: keyspace names are case-sensitive unless quoted at creation.
- Verify you are connecting to the intended cluster/node.
- Create the keyspace if it genuinely does not exist yet.
Example fix
// before nodetool compact UserKeyspace // after nodetool compact userkeyspace # matches actual case-sensitive keyspace name
Defensive patterns
Strategy: validation
Validate before calling
List<String> existing = probe.getKeyspaces();
List<String> requested = List.of("my_ks");
if (!existing.containsAll(requested))
throw new IllegalArgumentException("Unknown keyspace(s): " + requested.stream().filter(k -> !existing.contains(k)).toList()); Try / catch
try { keyspaces = CommandUtils.parseOptionalKeyspace(args, probe); }
catch (IllegalArgumentException e) { System.err.println(e.getMessage() + " — run 'DESCRIBE KEYSPACES' in cqlsh"); System.exit(2); } Prevention
- Validate keyspace names against cqlsh DESCRIBE KEYSPACES before scripting.
- Remember keyspace names are case-sensitive unless quoted at creation.
- Use consistent naming in automation to avoid case drift.
- Confirm which cluster nodetool is connected to before passing keyspaces.
When it happens
Trigger: Typing a misspelled or dropped keyspace name (including case mismatch, since comparison is case-sensitive) into any nodetool command that takes an optional keyspace: compact, cleanup, repair, flush, scrub, etc.
Common situations: Keyspace was dropped or never created; typo or wrong capitalization; connected to the wrong cluster/datacenter that lacks the keyspace; quoting issues splitting the name.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Can not parse replication factor %s
- Specify snapshot name or --all
- Specify only one of snapshot name or --all
- Specify only one of --older-than or --older-than-timestamp
- Specifying snapshot name together with --older-than flag is
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/a701c4d9f7ebd415.
Report an issue: GitHub.