{"record":{"id":"b98f852eeb8ac827","repo":"Dokploy/dokploy","slug":"conflict-b98f85","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/libsql.ts","lineNumber":25,"sourceCode":"} from \"@dokploy/server/db/schema\";\nimport { generatePassword } from \"@dokploy/server/templates\";\nimport { buildLibsql } from \"@dokploy/server/utils/databases/libsql\";\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 Libsql = typeof libsql.$inferSelect;\n\nexport const createLibsql = async (input: z.infer<typeof apiCreateLibsql>) => {\n\tconst appName = buildAppName(\"libsql\", input.appName);\n\n\tconst valid = await validUniqueServerAppName(input.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 newLibsql = await db\n\t\t.insert(libsql)\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 (!newLibsql) {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/libsql.ts#L7-L43","documentation":"Thrown by createLibsql when validUniqueServerAppName reports the chosen appName is already in use. Dokploy prefixes it ('libsql-<name>') and enforces globally unique app names per server, so this is a duplicate-key business-rule check mapped to HTTP 409 CONFLICT.","triggerScenarios":"Calling createLibsql with an appName that collides with an existing application/service name on the server (after the 'libsql-' prefix is applied by buildAppName).","commonSituations":"Re-running a setup script that recreates the same database, choosing a generic name like 'db' or 'main', or deleting an app in the UI while its name is still reserved in the database.","solutions":["Choose a different, more specific appName and retry","List existing apps (admin/apps endpoint) to see which name is taken","If the old service was supposed to be deleted, remove its row so the name frees up"],"exampleFix":"// before\nawait createLibsql({ appName: 'main' }); // 409 if 'libsql-main' exists\n\n// after\nawait createLibsql({ appName: 'main-prod-2026' });","handlingStrategy":"validation","validationCode":"const apps = await trpc.admin.listApps.query();\nconst nameTaken = apps.some(a => a.name === `libsql-${input.appName}`);\nif (nameTaken) throw new Error('AppName taken');","typeGuard":null,"tryCatchPattern":"try { await createLibsql(input); } catch (e) { if (e.shape?.data?.code === 'CONFLICT') { input.appName = `${input.appName}-${Date.now()}`; await createLibsql(input); } }","preventionTips":["Generate unique suffixes (project-env) in provisioning scripts","Check existing app names before submitting"],"tags":["validation","conflict","duplicate-app-name","libsql"],"backgroundTag":"duplicate-resource-name-conflict","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}