FlowiseAI/Flowise · error · Error

Invalid table name

Error message

Invalid table name

What it means

Thrown by SQLiteSaver.sanitizeTableName() when the (trim+lower+whitespace→underscore) tableName does not match ^[a-zA-Z0-9_]+$. This runs on every operation that interpolates the table name into SQL, so it is a pre-SQL injection / sanity guard.

Source

Thrown at packages/components/nodes/memory/AgentMemory/SQLiteAgentMemory/sqliteSaver.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
        const dataSource = new DataSource(datasourceOptions)
        await dataSource.initialize()
        return dataSource
    }

    private async setup(dataSource: DataSource): Promise<void> {
        if (this.isSetup) {
            return
        }

        try {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Use a plain alphanumeric+underscore table name, e.g. 'checkpoints', 'my_app_checkpoints'.
  2. Drop schema prefixes from tableName (the saver does not support them); configure the schema via datasourceOptions if needed.
  3. Convert kebab-case to snake_case before assigning.
  4. If you maintain the saver and need dotted names, extend sanitize to allow '.' and use TypeORM's identifier quoting.

Example fix

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

Strategy: validation

Validate before calling

const TABLE_NAME_RE = /^[a-zA-Z0-9_]+$/
function sanitizeOrRejectTableName(name: string): string {
  const normalized = name.trim().toLowerCase().replace(/\s+/g, '_')
  if (!TABLE_NAME_RE.test(normalized)) {
    throw new Error(`tableName '${name}' is invalid; use only letters, digits, and underscores`)
  }
  return normalized
}

Type guard

function isValidTableName(name: unknown): name is string {
  return typeof name === 'string' && /^[a-zA-Z0-9_]+$/.test(name.trim().toLowerCase().replace(/\s+/g, '_'))
}

Try / catch

try {
  saver.sanitizeTableName(proposedName)
} catch (e) {
  if ((e as Error).message === 'Invalid table name') {
    // fall back to a safe default rather than crashing
    proposedName = 'checkpoints'
  } else throw e
}

Prevention

When it happens

Trigger: Setting this.tableName to a value containing dots, hyphens, spaces-after-collapse-residue, Unicode, or that is empty after trim. Also triggered by schema-qualified names like public.checkpoints or quoted identifiers.

Common situations: Configuring a custom tableName with schema prefix or kebab-case. Empty/whitespace tableName from a missing input field. International characters in the name.

Related errors


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