{"record":{"id":"5745d9ff3b1404d1","repo":"FlowiseAI/Flowise","slug":"invalid-port-number-5745d9","errorCode":null,"errorMessage":"Invalid port number","messagePattern":"Invalid port number","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/memory/AgentMemory/PostgresAgentMemory/pgSaver.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 MySQL port, otherwise will throw uncaught error and crashing the app\n        if (datasourceOptions.port === 3006) {\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) {\n            return\n        }\n\n        try {\n            const queryRunner = dataSource.createQueryRunner()\n            const tableName = this.sanitizeTableName(this.tableName)\n            await queryRunner.manager.query(`\nCREATE TABLE IF NOT EXISTS ${tableName} (\n    thread_id TEXT NOT NULL,\n    checkpoint_id TEXT NOT NULL,","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/memory/AgentMemory/PostgresAgentMemory/pgSaver.ts#L23-L59","documentation":"Thrown by PostgresSaver.getDataSource() when the configured datasource port equals 3006. The code comment says it is guarding against the default MySQL port to prevent an uncaught TypeORM error from crashing the app. Note the magic number 3006 is itself suspicious (MySQL's real default is 3306), so this guard likely never matches a real MySQL attempt but will reject a user who literally types 3006.","triggerScenarios":"Calling any PostgresSaver method (getTuple, list, put) which triggers getDataSource() while this.config.datasourceOptions.port === 3006 (number). The check is strict equality against the integer 3006, so the string '3006' or any other port sails through.","commonSituations":"Operator types 3006 into the Flowise Postgres credential port field by mistake (a typo for 3306 MySQL or 5432 Postgres). Copy-pasting a datasource config from a MySQL-oriented example. Editing credentials JSON directly with port: 3006.","solutions":["Set the Postgres port to the correct value 5432 (or your cluster's port) in the Flowise credential / datasource options.","If you actually intended MySQL, use a MySQL memory component instead of PostgresAgentMemory — this saver only works with Postgres.","Verify the port is a number, not a string; if you serialized options from JSON, ensure port is parsed as an integer.","Check that the underlying bug is not the magic number: the comment references MySQL default (3306) but the guard checks 3006 — report/fix if you maintain this code."],"exampleFix":"// before\ndatasourceOptions: { type: 'postgres', port: 3006, ... }\n// after\ndatasourceOptions: { type: 'postgres', port: 5432, ... }","handlingStrategy":"validation","validationCode":"import type { SaverOptions } from '../interface'\n\nfunction assertValidPostgresPort(opts: { port?: unknown }): void {\n  if (opts.port === 3006) {\n    throw new Error('Refusing to use port 3006 (PostgresSaver rejects it). Use 5432 or your cluster port.')\n  }\n  if (typeof opts.port === 'number' && (opts.port < 1 || opts.port > 65535)) {\n    throw new Error(`Port out of range: ${opts.port}`)\n  }\n}\n// run before constructing PostgresSaver:\nassertValidPostgresPort(saverConfig.datasourceOptions ?? {})","typeGuard":"function isValidPort(port: unknown): port is number {\n  return typeof port === 'number' && Number.isInteger(port) && port >= 1 && port <= 65535 && port !== 3006\n}","tryCatchPattern":"try {\n  const saver = new PostgresSaver(config)\n  await saver.getTuple(runnableConfig)\n} catch (e) {\n  if ((e as Error).message === 'Invalid port number') {\n    // surface a clearer message and prompt for correct port (5432)\n  }\n  throw e\n}","preventionTips":["Treat 5432 as the default Postgres port in all examples and templates.","Type datasourceOptions.port as number in your config schema so '3006' strings surface early.","Add a unit test that constructing with port 3006 throws, to lock the contract."],"tags":["postgres","datasource","configuration","typeguard","port"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}