{"record":{"id":"27c0fa7b111d7c80","repo":"Dokploy/dokploy","slug":"bad-request-27c0fa","errorCode":"BAD_REQUEST","errorMessage":"Error creating the notification","messagePattern":"Error creating the notification","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"apps/dokploy/server/api/routers/notification.ts","lineNumber":122,"sourceCode":"\t\t\t\t\tresourceType: \"notification\",\n\t\t\t\t\tresourceName: input.name,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconsole.log(error);\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\t\tmessage: \"Error creating the notification\",\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t}),\n\tupdateSlack: withPermission(\"notification\", \"update\")\n\t\t.input(apiUpdateSlack)\n\t\t.mutation(async ({ input, ctx }) => {\n\t\t\ttry {\n\t\t\t\tconst notification = await findNotificationById(input.notificationId);\n\t\t\t\tif (notification.organizationId !== ctx.session.activeOrganizationId) {\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: \"UNAUTHORIZED\",\n\t\t\t\t\t\tmessage: \"You are not authorized to update this notification\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst result = await updateSlackNotification({\n\t\t\t\t\t...input,\n\t\t\t\t\torganizationId: ctx.session.activeOrganizationId,\n\t\t\t\t});\n\t\t\t\tawait audit(ctx, {\n\t\t\t\t\taction: \"update\",\n\t\t\t\t\tresourceType: \"notification\",\n\t\t\t\t\tresourceId: input.notificationId,\n\t\t\t\t\tresourceName: notification.name,\n\t\t\t\t});\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tthrow error;\n\t\t\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/notification.ts#L104-L140","documentation":"Dokploy wraps notification creation (the Slack create mutation at notification.ts ~line 110-125) in a try/catch that converts any underlying failure — invalid webhook URL, DB constraint, mailer config — into a tRPC BAD_REQUEST with the generic message 'Error creating the notification' and the original error attached as cause.","triggerScenarios":"Calling notification.createSlack (the mutation whose audit block has action \"create\") when createSlackNotification or the audit call rejects: malformed Slack webhook URL, missing required fields, or a database error.","commonSituations":"Invalid/partially configured Slack webhook (wrong workspace or truncated URL); duplicate notification names hitting a uniqueness constraint; DB connectivity issues during creation.","solutions":["Inspect error.cause on the TRPCError — the original rejection explains the real failure","Validate the Slack webhook URL format (https://hooks.slack.com/services/...) before submitting","Check required input fields against apiCreateSlack (zod) and fix validation errors surfaced client-side","Check server logs/DB health if cause is a database error"],"exampleFix":"// before\nawait trpc.notification.createSlack.mutate(input);\n// after\nif (!/^https:\\/\\/hooks\\.slack\\.com\\/services\\//.test(input.webhookUrl)) {\n  throw new Error('Invalid Slack webhook URL');\n}\nawait trpc.notification.createSlack.mutate(input).catch(e => { console.error(e.cause ?? e); throw e; });","handlingStrategy":"try-catch","validationCode":"if (!input.webhookUrl?.startsWith('https://hooks.slack.com/services/')) throw new Error('Invalid webhook');","typeGuard":"const isSlackWebhook = (u: string) => /^https:\\/\\/hooks\\.slack\\.com\\/services\\/[\\w-/.]+$/.test(u);","tryCatchPattern":"try { await create(input); } catch (e) { logAndShow(e.cause ?? e); }","preventionTips":["Validate webhook URLs client-side before submit","Never ignore error.cause — it carries the real failure"],"tags":["dokploy","trpc","notifications","slack","webhook"],"backgroundTag":"wrapped-api-error-cause-chained","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}