mem0ai/mem0 · error · Error
Invalid ${label} '${name}': only letters, digits, and unders
Error message
Invalid ${label} '${name}': only letters, digits, and underscores are allowed, must start with a letter or underscore, and be at most 128 characters. What it means
Keyspace and table names are interpolated into CQL by the Cassandra store, so validateIdentifier() rejects anything that does not match SAFE_IDENTIFIER_RE: letters, digits, and underscores only; must start with a letter or underscore; at most 128 characters. This is an injection guard that runs before any CQL is built.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/cassandra.ts:391
}
return new driver.Client(clientConfig);
}
// Loaded dynamically: cassandra-driver is an optional peer dependency, so a static
// value import would break `import { Memory } from "mem0ai/oss"` for everyone else.
private async loadDriver(): Promise<any> {
const sdk = await loadPeer(
"cassandra-driver",
"Cassandra vector store",
() => import("cassandra-driver"),
);
return sdk.default ?? sdk;
}
private validateIdentifier(name: string, label: string): string {
if (!SAFE_IDENTIFIER_RE.test(name)) {
throw new Error(
`Invalid ${label} '${name}': only letters, digits, and underscores are allowed, ` +
"must start with a letter or underscore, and be at most 128 characters.",
);
}
return name;
}
private cosineSimilarity(left: number[], right: number[]): number {
let dotProduct = 0;
let leftNorm = 0;
let rightNorm = 0;
for (let index = 0; index < left.length; index += 1) {
dotProduct += left[index] * right[index];
leftNorm += left[index] * left[index];
rightNorm += right[index] * right[index];
}
View on GitHub (pinned to 001c235229)
Solutions
- Rename the collection/identifier to use only [A-Za-z0-9_], starting with a letter or underscore, max 128 chars (e.g. 'user_memories' instead of 'user-memories')
- If the name comes from user input, sanitize it (replace invalid chars with '_', prefix an underscore if it starts with a digit) before passing it in
Example fix
// before
new Cassandra({ collectionName: 'user-memories', ... });
// after
new Cassandra({ collectionName: 'user_memories', ... }); Defensive patterns
Strategy: validation
Validate before calling
const SAFE_ID = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
function safeCassandraName(name: string): string {
const cleaned = name.replace(/[^A-Za-z0-9_]/g, '_').replace(/^([0-9])/, '_$1');
if (!SAFE_ID.test(cleaned)) throw new Error(`Cannot sanitize name: ${name}`);
return cleaned;
} Type guard
const isSafeIdentifier = (n: string): boolean => /^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(n); Prevention
- Prefer underscores over dashes/dots in collection names from day one
- Run user-provided names through a sanitizer before they reach the store config
When it happens
Trigger: Passing a collectionName, keyspace, or table name containing dashes, dots, spaces, or leading digits — e.g. collectionName: 'user-memories', 'mem0.prod', '2024logs' — to the Cassandra vector store config.
Common situations: Reusing a collection name from another vector store (Qdrant/Chroma allow dashes and dots); namespacing with dots like 'team.memory'; a name generated from user input that includes arbitrary characters.
Related errors
- Invalid ${label} '${name}': only letters, digits, and unders
- Invalid ${label} '${name}': only letters, digits, and unders
- Unknown providerOverride '${providerOverride}'. Valid provid
- Cassandra vector store requires contactPoints when secureCon
- Cassandra vector store requires localDataCenter when secureC
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/119a2fde054b805b.
Report an issue: GitHub.