mem0ai/mem0 · error · Error
Identifier name ${name} is not valid.
Error message
Identifier name ${name} is not valid. What it means
Oracle identifiers (table/index/column names) are quoted and interpolated into SQL by quoteIdentifier(). The regex allows dot-separated segments, optionally double-quoted, and nothing else. Names containing characters outside that grammar would break out of the quoted identifier or allow SQL injection, so invalid names are rejected before any SQL is built.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/oracledb.ts:49
> = {
HNSW: {
neighbors: [2, 2048],
efconstruction: [1, 65535],
},
IVF: {
"neighbor partitions": [1, 10_000_000],
samples_per_partition: [1, Number.MAX_SAFE_INTEGER],
min_vectors_per_partition: [0, Number.MAX_SAFE_INTEGER],
},
};
const IDENTIFIER_RE = /^(?:"[^"]+"|[^".]+)(?:\.(?:"[^"]+"|[^".]+))*$/;
const METADATA_KEY_RE = /^[a-zA-Z0-9_.[\],\s*]+$/;
export function quoteIdentifier(name: string): string {
const trimmed = name.trim();
if (!IDENTIFIER_RE.test(trimmed)) {
throw new Error(`Identifier name ${name} is not valid.`);
}
return [...trimmed.matchAll(/"([^"]+)"|([^".]+)/g)]
.map((m) => `"${m[1] ?? m[2]}"`)
.join(".");
}
function jsonPath(metadataKey: string): string {
if (!METADATA_KEY_RE.test(metadataKey)) {
throw new Error(
`Invalid metadata key '${metadataKey}'. Only letters, numbers, underscores, ` +
`nesting via '.', and array wildcards '[*]' are allowed.`,
);
}
return metadataKey
.split(".")
.map((part) =>
part.endsWith("[*]") ? `."${part.slice(0, -3)}"[*]` : `."${part}"`,
)View on GitHub (pinned to 001c235229)
Solutions
- Use simple alphanumeric names with optional dots and double quotes: MEMORIES, scott.MEMORIES.
- Never build table/index names from raw user input; map tenant IDs to a fixed allow-list of names.
- Strip dialect-specific quoting (backticks, square brackets) from names migrated from MySQL/MSSQL.
Example fix
// before
new OracleDB({ tableName: '`memories`' }); // MySQL-style backticks
// after
new OracleDB({ tableName: 'memories' }); Defensive patterns
Strategy: type-guard
Validate before calling
const IDENTIFIER = /^(?:"[^"]+"|[^".]+)(?:\.(?:"[^"]+"|[^".]+))*$/;
if (!IDENTIFIER.test(tableName.trim())) throw new TypeError(`Invalid Oracle identifier: ${tableName}`); Type guard
const isValidOracleIdentifier = (name: string): boolean => /^(?:"[^"]+"|[A-Za-z][A-Za-z0-9_$#]*)(?:\.(?:"[^"]+"|[A-Za-z][A-Za-z0-9_$#]*))*$/.test(name.trim());
Prevention
- Use fixed alphanumeric table/index names from config, never user input
- Map tenants to an allow-list of names
- Strip MySQL/MSSQL quoting when migrating schemas
When it happens
Trigger: Setting a table or index name containing characters like semicolons, quotes-with-nested-quotes, backticks, or stray whitespace patterns that fail IDENTIFIER_RE, e.g. config { tableName: 'memories; DROP TABLE x' }.
Common situations: Using unvalidated dynamic table names from tenant/user input; names copied from another database dialect with backticks (MySQL) or brackets (MSSQL); environment-specific naming with special characters.
Related errors
- Invalid ${label} '${name}': only letters, digits, and unders
- Invalid filter key: ${key}
- Invalid ${label} '${name}': only letters, digits, and unders
- Invalid ${label} '${name}': only letters, digits, and unders
- Databricks vector store: topK must be a positive integer, go
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/9ebfd2dcb218fd84.
Report an issue: GitHub.