Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error input: Inserting mysql database
What it means
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.
Source
Thrown at packages/server/src/services/mysql.ts:47
}
const newMysql = await db
.insert(mysql)
.values({
...input,
databasePassword: input.databasePassword
? input.databasePassword
: generatePassword(),
databaseRootPassword: input.databaseRootPassword
? input.databaseRootPassword
: generatePassword(),
appName,
})
.returning()
.then((value) => value[0]);
if (!newMysql) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error input: Inserting mysql database",
});
}
return newMysql;
};
// https://github.com/drizzle-team/drizzle-orm/discussions/1483#discussioncomment-7523881
export const findMySqlById = async (mysqlId: string) => {
const result = await db.query.mysql.findFirst({
where: eq(mysql.mysqlId, mysqlId),
with: {
environment: {
with: {
project: true,
},
},View on GitHub (pinned to 546686ea35)
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
Defensive patterns
Strategy: retry
Try / catch
try { await createMysql(input); } catch (e) { if (e instanceof TRPCError && e.message.includes("Inserting mysql")) await retry(createMysql, input, { retries: 2 }); else throw e; } Prevention
- Keep migrations applied
- Avoid transaction-mode poolers for service creation paths
When it happens
Trigger: 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.
Common situations: PgBouncer in transaction mode with prepared statements, a misconfigured migrations state leaving the table without expected defaults, flaky DB connections.
Understand the failure class
Background: BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries — this error's family across 8 libraries.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/4e0ec295268e7bfc.
Report an issue: GitHub.