{"record":{"id":"52943bfb2ac19649","repo":"Dokploy/dokploy","slug":"conflict-52943b","errorCode":"CONFLICT","errorMessage":"A DNS provider named \"${input.name}\" already exists in this organization","messagePattern":"A DNS provider named \"(.+?)\" already exists in this organization","errorType":"exception","errorClass":"TRPCError","httpStatus":409,"severity":"warning","filePath":"packages/server/src/services/dns-provider.ts","lineNumber":82,"sourceCode":"\t\t\t.values({\n\t\t\t\tname: input.name,\n\t\t\t\tproviderType: input.config.providerType,\n\t\t\t\tconfig: input.config,\n\t\t\t\torganizationId,\n\t\t\t})\n\t\t\t.returning()\n\t\t\t.then((value) => value[0]);\n\n\t\tif (!newProvider) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\tmessage: \"Error creating the DNS provider\",\n\t\t\t});\n\t\t}\n\t\treturn newProvider;\n\t} catch (error) {\n\t\tif (isUniqueNameViolation(error)) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\tmessage: `A DNS provider named \"${input.name}\" already exists in this organization`,\n\t\t\t});\n\t\t}\n\t\tthrow error;\n\t}\n};\n\nexport const findDnsProviderById = async (dnsProviderId: string) => {\n\tconst provider = await db.query.dnsProvider.findFirst({\n\t\twhere: eq(dnsProvider.dnsProviderId, dnsProviderId),\n\t});\n\tif (!provider) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"NOT_FOUND\",\n\t\t\tmessage: \"DNS provider not found\",\n\t\t});\n\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/dns-provider.ts#L64-L100","documentation":"createDnsProvider detects a unique-name violation (isUniqueNameViolation on the caught DB error) and rethrows as CONFLICT, indicating a DNS provider with the same name already exists in the organization. This enforces per-organization name uniqueness for DNS providers.","triggerScenarios":"POSTing a new DNS provider with a name that already exists within the same organization (e.g. two providers named \"Cloudflare prod\").","commonSituations":"Double-submitting the create form; retrying after a network error without realizing the first attempt succeeded; picking default names like the provider type that collide.","solutions":["Choose a different, unique name for the provider within the organization","List existing DNS providers first and reuse/update the existing one instead of creating a duplicate","Disable the submit button / dedupe retries in the client","If the row was actually created on a prior attempt, delete or rename the old one"],"exampleFix":"// before\nawait createDnsProvider({ name: \"cloudflare\", ... });\n// after: check for existing provider first\nconst existing = providers.find((p) => p.name === \"cloudflare\");\nif (existing) await updateDnsProvider(existing.dnsProviderId, {...});\nelse await createDnsProvider({ name: \"cloudflare\", ... });","handlingStrategy":"validation","validationCode":"const dupe = providers.some((p) => p.name === input.name);\nif (dupe) throw new Error(\"Name already used in this organization\");","typeGuard":null,"tryCatchPattern":"try { await createDnsProvider(input); } catch (e) { if (e instanceof TRPCError && e.code === \"CONFLICT\") { /* prompt for a new name */ } throw e; }","preventionTips":["Check existing provider names before create","Disable submit during in-flight requests","Use descriptive unique names"],"tags":["conflict","duplicate","dns","unique-constraint"],"backgroundTag":"duplicate-resource-name-conflict","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}