{"record":{"id":"76e0dc775c36a291","repo":"Dokploy/dokploy","slug":"bad-request-76e0dc","errorCode":"BAD_REQUEST","errorMessage":"Error creating the project","messagePattern":"Error creating the project","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/project.ts","lineNumber":34,"sourceCode":"import { createProductionEnvironment } from \"./environment\";\n\nexport type Project = typeof projects.$inferSelect;\n\nexport const createProject = async (\n\tinput: z.infer<typeof apiCreateProject>,\n\torganizationId: string,\n) => {\n\tconst newProject = await db\n\t\t.insert(projects)\n\t\t.values({\n\t\t\t...input,\n\t\t\torganizationId: organizationId,\n\t\t})\n\t\t.returning()\n\t\t.then((value) => value[0]);\n\n\tif (!newProject) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Error creating the project\",\n\t\t});\n\t}\n\n\t// Automatically create a production environment\n\tconst newEnvironment = await createProductionEnvironment(\n\t\tnewProject.projectId,\n\t);\n\treturn {\n\t\tproject: newProject,\n\t\tenvironment: newEnvironment,\n\t};\n};\n\nexport const serviceColumns = {\n\tname: true,\n\tdescription: true,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/project.ts#L16-L52","documentation":"createProject inserts a new project row via Drizzle's .returning() and expects the first returned row. If the insert returns no row (or undefined), it throws a tRPC BAD_REQUEST error indicating the database insert failed to produce a project record. This is a defensive guard after the insert rather than a user-input validation.","triggerScenarios":"POST to the createProject tRPC mutation where the underlying db.insert(...).returning() yields an empty result — e.g. a database trigger swallowing the insert, a failed constraint with silent handling, or a driver/ORM mismatch returning no rows.","commonSituations":"Rare DB edge cases: BEFORE INSERT triggers returning NULL, replication/rollback weirdness, Drizzle version changes altering .returning() behavior on the target database, or the insert silently failing due to schema drift between the Drizzle schema and the actual database tables.","solutions":["Check the database logs for why the insert produced no returned row (triggers, constraints, schema drift)","Verify the Drizzle schema matches the actual database (run migrations / drizzle-kit push) and that .returning() is supported for your DB engine","Retry the createProject call; if persistent, inspect the insert payload (organizationId, name) for constraint violations surfaced elsewhere"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await createProject(input) } catch (e) { if (e instanceof TRPCError && e.code === 'BAD_REQUEST' && e.message === 'Error creating the project') { /* surface as system error, retry once */ } }","preventionTips":["Keep Drizzle schema in sync with DB migrations","Monitor for BEFORE INSERT triggers on the projects table"],"tags":["trpc","drizzle","database-insert","project"],"backgroundTag":"database-insert-returned-no-rows","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}