{"record":{"id":"9c03879286d56f1b","repo":"Dokploy/dokploy","slug":"bad-request-9c0387","errorCode":"BAD_REQUEST","errorMessage":"Error input: Inserting mongo database","messagePattern":"Error input: Inserting mongo database","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/mongo.ts","lineNumber":45,"sourceCode":"\t\t\tcode: \"CONFLICT\",\n\t\t\tmessage: \"Service with this 'AppName' already exists\",\n\t\t});\n\t}\n\n\tconst newMongo = await db\n\t\t.insert(mongo)\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\tappName,\n\t\t})\n\t\t.returning()\n\t\t.then((value) => value[0]);\n\n\tif (!newMongo) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Error input: Inserting mongo database\",\n\t\t});\n\t}\n\n\treturn newMongo;\n};\n\nexport const findMongoById = async (mongoId: string) => {\n\tconst result = await db.query.mongo.findFirst({\n\t\twhere: eq(mongo.mongoId, mongoId),\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},\n\t\t\tmounts: true,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/mongo.ts#L27-L63","documentation":"Thrown by createMongo when the Drizzle INSERT into the mongo table with .returning() yields no row — the database-level insert failed after the uniqueness check passed.","triggerScenarios":"A NOT NULL/enum/foreign-key violation on the mongo table insert, a dropped connection, or a concurrent create race that beats this request between check and insert.","commonSituations":"Schema drift after an upgrade, missing column defaults, or parallel provisioning scripts racing on similar names.","solutions":["Inspect server logs for the Postgres error behind the failed insert","If it's a race, re-fetch: the row may exist under the same name (treat as 409)","Apply pending Drizzle migrations"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await createMongo(input); } catch (e) { if (e.shape?.data?.code === 'BAD_REQUEST') { await verifyOrCreateWithUniqueName(input); } }","preventionTips":["Avoid parallel creates with the same appName","Keep Drizzle migrations in sync"],"tags":["database","drizzle-orm","mongodb","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"}