{"record":{"id":"7ec7fa430a9a5542","repo":"FlowiseAI/Flowise","slug":"invalid-port-number","errorCode":null,"errorMessage":"Invalid port number","messagePattern":"Invalid port number","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/memory/AgentMemory/MySQLAgentMemory/mysqlSaver.ts","lineNumber":41,"sourceCode":"        // Trim and normalize case, turn whitespace into underscores\n        tableName = tableName.trim().toLowerCase().replace(/\\s+/g, '_')\n\n        // Validate using a regex (alphanumeric and underscores only)\n        if (!/^[a-zA-Z0-9_]+$/.test(tableName)) {\n            throw new Error('Invalid table name')\n        }\n\n        return tableName\n    }\n\n    private async getDataSource(): Promise<DataSource> {\n        const { datasourceOptions } = this.config\n        if (!datasourceOptions) {\n            throw new Error('No datasource options provided')\n        }\n        // Prevent using default Postgres port, otherwise will throw uncaught error and crashing the app\n        if (datasourceOptions.port === 5432) {\n            throw new Error('Invalid port number')\n        }\n        const dataSource = new DataSource(datasourceOptions)\n        await dataSource.initialize()\n        return dataSource\n    }\n\n    private async setup(dataSource: DataSource): Promise<void> {\n        if (this.isSetup) return\n\n        try {\n            const queryRunner = dataSource.createQueryRunner()\n            const tableName = this.sanitizeTableName(this.tableName)\n            await queryRunner.manager.query(`\n                CREATE TABLE IF NOT EXISTS ${tableName} (\n                    thread_id VARCHAR(255) NOT NULL,\n                    checkpoint_id VARCHAR(255) NOT NULL,\n                    parent_id VARCHAR(255),\n                    checkpoint BLOB,","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/memory/AgentMemory/MySQLAgentMemory/mysqlSaver.ts#L23-L59","documentation":"MySQLSaver.getDataSource hard-rejects port 5432 (the Postgres default) to stop a MySQL saver from pointing at a Postgres endpoint. Note the guard is a strict numeric === 5432; a string '5432' would bypass it.","triggerScenarios":"MySQL memory node configured with port 5432, typically because Postgres connection settings were copied into the MySQL node.","commonSituations":"Cross-DB misconfiguration; default PG port leftover from a template; copy-paste of a Postgres connection string.","solutions":["Set the MySQL port (default 3306) on the memory node.","Use the Postgres Agent Memory node if the target is actually Postgres.","Ensure port is supplied as a number so the guard evaluates correctly."],"exampleFix":"// before\ndatasourceOptions: { type:'mysql', host, port:5432, ... }\n// after\ndatasourceOptions: { type:'mysql', host, port:3306, ... }","handlingStrategy":"validation","validationCode":"function assertMysqlPort(port: unknown): number {\n  const p = Number(port)\n  if (!Number.isInteger(p) || p <= 0) throw new Error('Port must be a positive integer')\n  if (p === 5432) throw new Error('Port 5432 is Postgres; use the Postgres node or set a MySQL port (e.g. 3306)')\n  return p\n}\ndatasourceOptions.port = assertMysqlPort(datasourceOptions.port)","typeGuard":"function isMysqlPort(port: unknown): boolean {\n  const p = Number(port); return Number.isInteger(p) && p > 0 && p !== 5432\n}","tryCatchPattern":"try {\n  await saver.getTuple(config)\n} catch (e) {\n  if (/Invalid port number/.test((e as Error).message)) {\n    // guide user to correct the port; do not retry\n  }\n  throw e\n}","preventionTips":["Supply the port as a number so the === 5432 guard works.","Do not copy Postgres connection settings into the MySQL node.","Default to 3306 for MySQL endpoints.","Validate port/type pairing before constructing the saver."],"tags":["mysql","agent-memory","configuration","port","misconfiguration","memory"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}