{"record":{"id":"4e0ec295268e7bfc","repo":"Dokploy/dokploy","slug":"bad-request-4e0ec2","errorCode":"BAD_REQUEST","errorMessage":"Error input: Inserting mysql database","messagePattern":"Error input: Inserting mysql database","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/mysql.ts","lineNumber":47,"sourceCode":"\t}\n\n\tconst newMysql = await db\n\t\t.insert(mysql)\n\t\t.values({\n\t\t\t...input,\n\t\t\tdatabasePassword: input.databasePassword\n\t\t\t\t? input.databasePassword\n\t\t\t\t: generatePassword(),\n\t\t\tdatabaseRootPassword: input.databaseRootPassword\n\t\t\t\t? input.databaseRootPassword\n\t\t\t\t: generatePassword(),\n\t\t\tappName,\n\t\t})\n\t\t.returning()\n\t\t.then((value) => value[0]);\n\n\tif (!newMysql) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Error input: Inserting mysql database\",\n\t\t});\n\t}\n\n\treturn newMysql;\n};\n\n// https://github.com/drizzle-team/drizzle-orm/discussions/1483#discussioncomment-7523881\nexport const findMySqlById = async (mysqlId: string) => {\n\tconst result = await db.query.mysql.findFirst({\n\t\twhere: eq(mysql.mysqlId, mysqlId),\n\t\twith: {\n\t\t\tenvironment: {\n\t\t\t\twith: {\n\t\t\t\t\tproject: true,\n\t\t\t\t},\n\t\t\t},","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/mysql.ts#L29-L65","documentation":"After the INSERT into the mysql table with .returning().then(v => v[0]), the code throws BAD_REQUEST when the returned row is falsy. This only happens when the insert silently returns no row — an abnormal DB/driver state, since a successful insert normally returns the row.","triggerScenarios":"Database connection dropping mid-statement, a RETURNING clause not supported/misbehaving (e.g. certain SQLite/pg proxies or pgbouncer transaction pooling quirks), or a constraint trigger that converts the statement into a no-op.","commonSituations":"PgBouncer in transaction mode with prepared statements, a misconfigured migrations state leaving the table without expected defaults, flaky DB connections.","solutions":["Check DB server logs for the failing INSERT around that timestamp","Verify the database connection (direct vs pooled) supports RETURNING","Retry the request — transient connection issues are the most common cause","Inspect the mysql table schema for missing defaults/NOT NULL columns that make the insert fail silently in the driver"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await createMysql(input); } catch (e) { if (e instanceof TRPCError && e.message.includes(\"Inserting mysql\")) await retry(createMysql, input, { retries: 2 }); else throw e; }","preventionTips":["Keep migrations applied","Avoid transaction-mode poolers for service creation paths"],"tags":["mysql","database","insert"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}