FlowiseAI/Flowise · error · Error

Invalid table name

Error message

Invalid table name

What it means

MySQLSaver.sanitizeTableName trims, lowercases, replaces whitespace with underscores, then requires the result to match ^[a-zA-Z0-9_]+$. Any other character (hyphen, dot, unicode, schema prefix) throws. Default tableName is 'checkpoints', which always passes.

Source

Thrown at packages/components/nodes/memory/AgentMemory/MySQLAgentMemory/mysqlSaver.ts:28

    protected isSetup: boolean
    config: SaverOptions
    threadId: string
    tableName = 'checkpoints'

    constructor(config: SaverOptions, serde?: SerializerProtocol<Checkpoint>) {
        super(serde)
        this.config = config
        const { threadId } = config
        this.threadId = threadId
    }

    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 { datasourceOptions } = this.config
        if (!datasourceOptions) {
            throw new Error('No datasource options provided')
        }
        // Prevent using default Postgres port, otherwise will throw uncaught error and crashing the app
        if (datasourceOptions.port === 5432) {
            throw new Error('Invalid port number')
        }
        const dataSource = new DataSource(datasourceOptions)
        await dataSource.initialize()
        return dataSource
    }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Restrict tableName to letters, digits, and underscores only.
  2. Replace hyphens/dots with underscores (my_checkpoints).
  3. Leave tableName at the default 'checkpoints' unless a custom name is required.

Example fix

// before
tableName = 'app.checkpoints'
// after
tableName = 'app_checkpoints'
Defensive patterns

Strategy: validation

Validate before calling

function safeTableName(name: string): string {
  const cleaned = name.trim().toLowerCase().replace(/\s+/g, '_')
  if (!/^[a-z0-9_]+$/.test(cleaned)) throw new Error(`Invalid table name: ${name}`)
  return cleaned
}
const tableName = safeTableName(userTableName ?? 'checkpoints')

Type guard

function isValidTableName(name: string): boolean {
  return /^[A-Za-z0-9_]+$/.test(name.trim().toLowerCase().replace(/\s+/g, '_'))
}

Try / catch

try {
  saver.sanitizeTableName(userTableName)
} catch (e) {
  throw new Error(`Choose a table name using only letters, digits, underscores: ${(e as Error).message}`)
}

Prevention

When it happens

Trigger: Overriding tableName to a value containing characters outside [A-Za-z0-9_], e.g. 'app.checkpoints', 'my-checkpoints', 'checkpoint_é'.

Common situations: Using a schema-qualified or hyphenated table name; copying a Postgres schema.table convention into the MySQL saver; unicode in the name.

Related errors


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