Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error input: Inserting mariadb database
What it means
Thrown by createMariadb when the Drizzle INSERT into the mariadb table with .returning() returns no row. The insert failed at the database level (constraint violation, schema mismatch, connectivity) despite passing the uniqueness pre-check.
Source
Thrown at packages/server/src/services/mariadb.ts:49
}
const newMariadb = await db
.insert(mariadb)
.values({
...input,
databasePassword: input.databasePassword
? input.databasePassword
: generatePassword(),
databaseRootPassword: input.databaseRootPassword
? input.databaseRootPassword
: generatePassword(),
appName,
})
.returning()
.then((value) => value[0]);
if (!newMariadb) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error input: Inserting mariadb database",
});
}
return newMariadb;
};
// https://github.com/drizzle-team/drizzle-orm/discussions/1483#discussioncomment-7523881
export const findMariadbById = async (mariadbId: string) => {
const result = await db.query.mariadb.findFirst({
where: eq(mariadb.mariadbId, mariadbId),
with: {
environment: {
with: {
project: true,
},
},View on GitHub (pinned to 546686ea35)
Solutions
- Inspect server logs for the underlying Postgres error
- Handle the race: if the row actually exists, treat it as a 409 and reuse/rename
- Run migrations to sync schema after upgrades
Defensive patterns
Strategy: try-catch
Try / catch
try { await createMariadb(input); } catch (e) { if (e.shape?.data?.code === 'BAD_REQUEST') { const apps = await listApps(); if (apps.some(a => a.name === name)) throw new ConflictError(); throw e; } } Prevention
- Serialize provisioning calls per appName to avoid races
- Keep DB schema migrations current
When it happens
Trigger: Calling createMariadb where the INSERT hits a NOT NULL/enum/foreign-key violation, or the connection drops between the uniqueness check and the insert (a race with a concurrent create also surfaces here).
Common situations: Concurrent provisioning scripts racing on the same name (check passes for both, insert fails for one), schema drift after upgrade, missing defaults on new columns.
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/caca3ca3526844be.
Report an issue: GitHub.