{"record":{"id":"476146986be593a8","repo":"Dokploy/dokploy","slug":"conflict-476146","errorCode":"CONFLICT","errorMessage":"Service with this 'AppName' already exists","messagePattern":"Service with this 'AppName' already exists","errorType":"exception","errorClass":"TRPCError","httpStatus":409,"severity":"warning","filePath":"packages/server/src/services/mongo.ts","lineNumber":26,"sourceCode":"} from \"@dokploy/server/db/schema\";\nimport { generatePassword } from \"@dokploy/server/templates\";\nimport { buildMongo } from \"@dokploy/server/utils/databases/mongo\";\nimport { pullImage } from \"@dokploy/server/utils/docker/utils\";\nimport { execAsyncRemote } from \"@dokploy/server/utils/process/execAsync\";\nimport { TRPCError } from \"@trpc/server\";\nimport { eq, getTableColumns } from \"drizzle-orm\";\nimport { quote } from \"shell-quote\";\nimport type { z } from \"zod\";\nimport { validUniqueServerAppName } from \"./project\";\n\nexport type Mongo = typeof mongo.$inferSelect;\n\nexport const createMongo = async (input: z.infer<typeof apiCreateMongo>) => {\n\tconst appName = buildAppName(\"mongo\", input.appName);\n\n\tconst valid = await validUniqueServerAppName(appName);\n\tif (!valid) {\n\t\tthrow new TRPCError({\n\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) {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/mongo.ts#L8-L44","documentation":"Thrown by createMongo when validUniqueServerAppName finds the prefixed appName ('mongo-<name>') already taken. Standard Dokploy duplicate-name guard returning HTTP 409 CONFLICT before any insert happens.","triggerScenarios":"Calling createMongo with an appName whose 'mongo-'-prefixed form collides with an existing app/service name.","commonSituations":"Repeated scripted provisioning with fixed names, generic names like 'mongo' already reserved, or names held by soft-deleted rows.","solutions":["Choose a unique appName","List existing apps to identify the collision","Fully remove the obsolete service to release the name"],"exampleFix":"// before\nawait createMongo({ appName: 'mongo' }); // 409\n\n// after\nawait createMongo({ appName: 'mongo-session-store' });","handlingStrategy":"validation","validationCode":"const apps = await trpc.admin.listApps.query();\nif (apps.some(a => a.name === `mongo-${input.appName}`)) throw new Error('Name taken');","typeGuard":null,"tryCatchPattern":"try { await createMongo(input); } catch (e) { if (e.shape?.data?.code === 'CONFLICT') { input.appName = uniqueify(input.appName); await createMongo(input); } }","preventionTips":["Use descriptive, environment-scoped names","Check existing names before scripted creates"],"tags":["validation","conflict","duplicate-app-name","mongodb"],"backgroundTag":"duplicate-resource-name-conflict","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}