Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error inserting mount
What it means
Thrown by createMount when the Drizzle insert into the mount table with .returning() returns no row. The insert itself failed at the database level, typically a constraint violation or schema issue, and is surfaced as BAD_REQUEST.
Source
Thrown at packages/server/src/services/mount.ts:62
}),
...(input.serviceType === "mongo" && {
mongoId: serviceId,
}),
...(input.serviceType === "mysql" && {
mysqlId: serviceId,
}),
...(input.serviceType === "postgres" && {
postgresId: serviceId,
}),
...(input.serviceType === "redis" && {
redisId: serviceId,
}),
})
.returning()
.then((value) => value[0]);
if (!value) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error inserting mount",
});
}
if (value.type === "file") {
await createFileMount(value.mountId);
}
return value;
} catch (error) {
console.log(error);
throw new TRPCError({
code: "BAD_REQUEST",
message: `Error ${error instanceof Error ? error.message : error}`,
cause: error,
});
}
};View on GitHub (pinned to 546686ea35)
Solutions
- Check server logs for the underlying Postgres error
- Confirm the target application/compose still exists and serviceId is valid
- Ensure type is exactly 'file' or 'volume' per the schema
- Run pending migrations
Defensive patterns
Strategy: validation
Validate before calling
const app = await trpc.application.byId.query({ appId });
if (!app) throw new Error('Target application missing');
if (!['file', 'volume'].includes(input.type)) throw new Error('Invalid mount type'); Type guard
const isValidMountType = (t: string): t is 'file' | 'volume' => t === 'file' || t === 'volume';
Try / catch
try { await createMount(input); } catch (e) { if (e.shape?.data?.code === 'BAD_REQUEST') { /* verify serviceId FK and type enum, check server logs */ } } Prevention
- Validate serviceId exists before creating mounts
- Restrict mount type to schema enums client-side
When it happens
Trigger: Calling createMount with a serviceId that violates a foreign key, a type value outside the expected enum ('file'/'volume'), or when the DB connection fails mid-insert.
Common situations: Creating a mount for an application that was just deleted (FK violation), schema drift on the mount table after upgrades, or an invalid mount type string.
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/3301971cf24faf9c.
Report an issue: GitHub.