{"record":{"id":"7545e18eb660fd3f","repo":"Dokploy/dokploy","slug":"bad-request-7545e1","errorCode":"BAD_REQUEST","errorMessage":"Error input: Inserting slack","messagePattern":"Error input: Inserting slack","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/notification.ts","lineNumber":62,"sourceCode":"\nexport type Notification = typeof notifications.$inferSelect;\n\nexport const createSlackNotification = async (\n\tinput: z.infer<typeof apiCreateSlack>,\n\torganizationId: string,\n) => {\n\tawait db.transaction(async (tx) => {\n\t\tconst newSlack = await tx\n\t\t\t.insert(slack)\n\t\t\t.values({\n\t\t\t\tchannel: input.channel,\n\t\t\t\twebhookUrl: input.webhookUrl,\n\t\t\t})\n\t\t\t.returning()\n\t\t\t.then((value) => value[0]);\n\n\t\tif (!newSlack) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\tmessage: \"Error input: Inserting slack\",\n\t\t\t});\n\t\t}\n\n\t\tconst newDestination = await tx\n\t\t\t.insert(notifications)\n\t\t\t.values({\n\t\t\t\tslackId: newSlack.slackId,\n\t\t\t\tname: input.name,\n\t\t\t\tappDeploy: input.appDeploy,\n\t\t\t\tappBuildError: input.appBuildError,\n\t\t\t\tdatabaseBackup: input.databaseBackup,\n\t\t\t\tdokployBackup: input.dokployBackup,\n\t\t\t\tvolumeBackup: input.volumeBackup,\n\t\t\t\tdokployRestart: input.dokployRestart,\n\t\t\t\tdockerCleanup: input.dockerCleanup,\n\t\t\t\tnotificationType: \"slack\",","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/notification.ts#L44-L80","documentation":"Inside a transaction, createSlackNotification inserts into the slack table with .returning(); if no row comes back it throws BAD_REQUEST 'Error input: Inserting slack', which aborts the tx (the companion notification destination insert never runs).","triggerScenarios":"DB driver/connection failure mid-transaction, schema drift on the slack table, or a pooler that mishandles RETURNING inside transactions.","commonSituations":"Migrations not applied (missing slack table/columns), pgbouncer transaction-pooling quirks, transient connection resets.","solutions":["Apply/verify migrations for the slack table","Check DB logs for the aborted INSERT","Retry — transient failures commonly surface here","Validate the DB connection supports RETURNING (avoid transaction-mode poolers for DDL-ish flows)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await createSlackNotification(input); } catch (e) { if (e instanceof TRPCError && e.message.includes(\"Inserting slack\")) await backoffRetry(2); else throw e; }","preventionTips":["Run migrations before enabling Slack notifications","Verify webhookUrl is a valid https URL client-side to avoid tx churn"],"tags":["slack","notification","database","insert"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}