FlowiseAI/Flowise · error · Error

Invalid table name

Error message

Invalid table name

What it means

Thrown by MySQLRecordManager.sanitizeTableName after the supplied table name is trimmed, lowercased, and whitespace-collapsed. The guard rejects any name whose characters fall outside [a-zA-Z0-9_], which protects the raw string interpolation used later in INSERT/CREATE TABLE SQL. It is a deliberately strict allow-list because the value is concatenated into a query template rather than parameterized.

Source

Thrown at packages/components/nodes/recordmanager/MySQLRecordManager/MySQLrecordManager.ts:190

    lc_namespace = ['langchain', 'recordmanagers', 'mysql']
    config: MySQLRecordManagerOptions
    tableName: string
    namespace: string

    constructor(namespace: string, config: MySQLRecordManagerOptions) {
        const { tableName } = config
        this.namespace = namespace
        this.tableName = tableName || 'upsertion_records'
        this.config = config
    }

    sanitizeTableName(tableName: string): string {
        // Trim and normalize case, turn whitespace into underscores
        tableName = tableName.trim().toLowerCase().replace(/\s+/g, '_')

        // Validate using a regex (alphanumeric and underscores only)
        if (!/^[a-zA-Z0-9_]+$/.test(tableName)) {
            throw new Error('Invalid table name')
        }

        return tableName
    }

    private async getDataSource(): Promise<DataSource> {
        const { mysqlOptions } = this.config
        if (!mysqlOptions) {
            throw new Error('No datasource options provided')
        }
        // Prevent using default Postgres port, otherwise will throw uncaught error and crashing the app
        if (mysqlOptions.port === 5432) {
            throw new Error('Invalid port number')
        }
        const dataSource = new DataSource(mysqlOptions)
        await dataSource.initialize()
        return dataSource
    }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Rename the table to use only letters, digits, and underscores (e.g. 'upsertion_records', 'my_table').
  2. Strip any schema/database prefix before passing the value; the manager writes to a single database.
  3. If you must keep a hyphenated name, pre-check with /^[a-zA-Z0-9_]+$/ and reject upstream in the Flowise UI rather than at runtime.
  4. Verify no invisible characters remain: tableName.trim() already runs, so the failure is a genuine disallowed character.

Example fix

// before
const tableName = 'flowise-records'
// after
const tableName = 'flowise_records'
Defensive patterns

Strategy: validation

Validate before calling

function isValidTableName(name: string): boolean {
  return typeof name === 'string' && /^[a-zA-Z0-9_]+$/.test(name.trim().toLowerCase().replace(/\s+/g, '_'))
}
// before calling init:
if (!isValidTableName(userTableName)) {
  throw new Error('Table name may only contain letters, digits, and underscores.')
}

Type guard

function isSafeTableName(name: unknown): name is string {
  return typeof name === 'string' && /^[a-zA-Z0-9_]+$/.test(name)
}

Try / catch

// sanitizeTableName is synchronous and non-retryable; validate pre-flight instead.
// If wrapping init: catch and surface to the user as a config error, do not retry.
try {
  await recordManager.createSchema()
} catch (e) {
  if (e instanceof Error && e.message === 'Invalid table name') {
    // surface to UI; do not retry with the same name
  }
  throw e
}

Prevention

When it happens

Trigger: Passing a tableName (via config.tableName or nodeData input) containing hyphens, dots, spaces that survive normalization, quotes, unicode, or any non-ASCII punctuation. A schema-qualified name like 'mydb.records' or a name with a leading digit-only segment after another violation also triggers it.

Common situations: User enters 'my-table' or 'flowise.records' in the Record Manager node's tableName field; copy-pasting a table name with a trailing newline or hidden BOM; migrating from Postgres (where sanitizeRecordManagerTableName is more permissive) to MySQL and reusing the same name.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/415f4c796a6d6612. Report an issue: GitHub.