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

Databricks catalog/schema/table/index names are interpolated into SQL and Management API calls, so validateIdentifier() enforces SAFE_IDENTIFIER_RE: letters, digits, underscores only; must start with a letter or underscore; at most 128 characters. Invalid names are rejected before any request is made.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/databricks.ts:89

  indexName: string,
  operation: "ReadVectorIndex" | "WriteVectorIndex",
): string {
  return JSON.stringify([
    {
      type: "unity_catalog_permission",
      securable_type: "table",
      securable_object_name: indexName,
      operation,
    },
  ]);
}

function validateIdentifier(
  name: string,
  label: string = "identifier",
): 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;
}

function extractHostAndWorkspaceUrl(config: DatabricksConfig): {
  host: string;
  workspaceUrl: string;
} {
  if (config.workspaceUrl) {
    const url = new URL(config.workspaceUrl);
    return {
      host: url.host,
      workspaceUrl: `${url.protocol}//${url.host}`,
    };
  }

View on GitHub (pinned to 001c235229)

Solutions

  1. Use underscores instead of dashes/dots in catalog, schema, tableName, and indexName (e.g. 'mem0_memories')
  2. Pass each identifier separately (catalog, schema, tableName), not one dotted string
  3. Sanitize dynamically generated names before constructing the store

Example fix

// before
new Databricks({ catalog: 'main', schema: 'default', tableName: 'mem-memories' });

// after
new Databricks({ catalog: 'main', schema: 'default', tableName: 'mem_memories' });
Defensive patterns

Strategy: validation

Validate before calling

const SAFE_ID = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
function safeDatabricksName(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 identifier: ${name}`);
  return cleaned;
}

Type guard

const isSafeIdentifier = (n: string): boolean => /^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(n);

Prevention

When it happens

Trigger: Configuring the Databricks store with catalog: 'main', schema: 'default', tableName: 'mem0-memories' (dash), or an indexName containing dots/dashes/spaces, or a name longer than 128 chars.

Common situations: Defaulting to hyphenated table names from other databases; using a fully-qualified 'catalog.schema.table' string as tableName; names sourced from tenant/user input with arbitrary characters.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/f6ac7616b143348e. Report an issue: GitHub.