{"record":{"id":"3301971cf24faf9c","repo":"Dokploy/dokploy","slug":"bad-request-330197","errorCode":"BAD_REQUEST","errorMessage":"Error inserting mount","messagePattern":"Error inserting mount","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/mount.ts","lineNumber":62,"sourceCode":"\t\t\t\t}),\n\t\t\t\t...(input.serviceType === \"mongo\" && {\n\t\t\t\t\tmongoId: serviceId,\n\t\t\t\t}),\n\t\t\t\t...(input.serviceType === \"mysql\" && {\n\t\t\t\t\tmysqlId: serviceId,\n\t\t\t\t}),\n\t\t\t\t...(input.serviceType === \"postgres\" && {\n\t\t\t\t\tpostgresId: serviceId,\n\t\t\t\t}),\n\t\t\t\t...(input.serviceType === \"redis\" && {\n\t\t\t\t\tredisId: serviceId,\n\t\t\t\t}),\n\t\t\t})\n\t\t\t.returning()\n\t\t\t.then((value) => value[0]);\n\n\t\tif (!value) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\tmessage: \"Error inserting mount\",\n\t\t\t});\n\t\t}\n\n\t\tif (value.type === \"file\") {\n\t\t\tawait createFileMount(value.mountId);\n\t\t}\n\t\treturn value;\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: `Error ${error instanceof Error ? error.message : error}`,\n\t\t\tcause: error,\n\t\t});\n\t}\n};","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/mount.ts#L44-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const app = await trpc.application.byId.query({ appId });\nif (!app) throw new Error('Target application missing');\nif (!['file', 'volume'].includes(input.type)) throw new Error('Invalid mount type');","typeGuard":"const isValidMountType = (t: string): t is 'file' | 'volume' => t === 'file' || t === 'volume';","tryCatchPattern":"try { await createMount(input); } catch (e) { if (e.shape?.data?.code === 'BAD_REQUEST') { /* verify serviceId FK and type enum, check server logs */ } }","preventionTips":["Validate serviceId exists before creating mounts","Restrict mount type to schema enums client-side"],"tags":["database","drizzle-orm","mount","insert"],"backgroundTag":"database-insert-returned-no-row","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}