{"record":{"id":"41759bc736f4c990","repo":"Dokploy/dokploy","slug":"bad-request-41759b","errorCode":"BAD_REQUEST","errorMessage":"Error creating tag: ${error instanceof Error ? error.message : error}","messagePattern":"Error creating tag: (.+?)","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"apps/dokploy/server/api/routers/tag.ts","lineNumber":42,"sourceCode":"\t\t\t\t\t.values({\n\t\t\t\t\t\tname: input.name,\n\t\t\t\t\t\tcolor: input.color,\n\t\t\t\t\t\torganizationId: ctx.session.activeOrganizationId,\n\t\t\t\t\t})\n\t\t\t\t\t.returning();\n\n\t\t\t\treturn newTag[0];\n\t\t\t} catch (error) {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\terror.message.includes(\"unique_org_tag_name\")\n\t\t\t\t) {\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\t\t\tmessage: \"A tag with this name already exists in your organization\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\t\tmessage: `Error creating tag: ${error instanceof Error ? error.message : error}`,\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t}),\n\n\tall: protectedProcedure.query(async ({ ctx }) => {\n\t\ttry {\n\t\t\tconst organizationTags = await db.query.tags.findMany({\n\t\t\t\twhere: eq(tags.organizationId, ctx.session.activeOrganizationId),\n\t\t\t\torderBy: (tags, { asc }) => [asc(tags.name)],\n\t\t\t});\n\n\t\t\treturn organizationTags;\n\t\t} catch (error) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"INTERNAL_SERVER_ERROR\",","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/tag.ts#L24-L60","documentation":"Catch-all in tag.create: any error other than the unique_org_tag_name conflict is rethrown as BAD_REQUEST with the original error message embedded. Commonly wraps Drizzle/Postgres failures such as NOT NULL violations, invalid identifiers, or connection problems during the insert.","triggerScenarios":"tag.create throwing for reasons other than a duplicate name — DB unreachable mid-insert, schema drift (missing column after an incomplete migration), or invalid input that slipped past zod validation.","commonSituations":"Database migration not applied after upgrading Dokploy; transient DB outage; manually edited schema; Postgres extension/permission issues.","solutions":["Read the embedded error.message — it names the real Postgres/Drizzle cause","Run pending migrations (dokploy upgrade / db push) so the tags table matches the code","Verify DB connectivity and credentials, then retry the create","If the message mentions a constraint or column, fix the input or schema accordingly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await api.tag.create({ name }); }\ncatch (e) {\n  const msg = e.message ?? '';\n  if (e.shape?.data?.code === 'CONFLICT') return; // duplicate\n  if (/connection|ECONNREFUSED|timeout/i.test(msg)) retryLater();\n  else throw e;\n}","preventionTips":["Apply migrations on every Dokploy upgrade","Monitor DB connectivity","Surface the embedded error.message in logs — it names the real cause"],"tags":["tag","database","drizzle","catch-all","trpc"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}