{"record":{"id":"6db6bb12e7fa32e8","repo":"Dokploy/dokploy","slug":"failed-to-create-rollback","errorCode":null,"errorMessage":"Failed to create rollback","messagePattern":"Failed to create rollback","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/services/rollbacks.ts","lineNumber":46,"sourceCode":"import {\n\tfindRegistryByIdWithCredentials,\n\ttype Registry,\n\tsafeDockerLoginCommand,\n} from \"./registry\";\n\nexport const createRollback = async (\n\tinput: z.infer<typeof createRollbackSchema>,\n) => {\n\treturn await db.transaction(async (tx) => {\n\t\tconst { fullContext, ...other } = input;\n\t\tconst rollback = await tx\n\t\t\t.insert(rollbacks)\n\t\t\t.values(other)\n\t\t\t.returning()\n\t\t\t.then((res) => res[0]);\n\n\t\tif (!rollback) {\n\t\t\tthrow new Error(\"Failed to create rollback\");\n\t\t}\n\n\t\tconst tagImage = `${input.appName}:v${rollback.version}`;\n\t\tconst deployment = await findDeploymentById(rollback.deploymentId);\n\n\t\tif (!deployment?.applicationId) {\n\t\t\tthrow new Error(\"Deployment not found\");\n\t\t}\n\n\t\tconst {\n\t\t\tdeployments: _,\n\t\t\tbitbucket,\n\t\t\tgithub,\n\t\t\tgitlab,\n\t\t\tgitea,\n\t\t\t...rest\n\t\t} = await findApplicationById(deployment.applicationId);\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/rollbacks.ts#L28-L64","documentation":"In createRollback's transaction, the insert into `rollbacks` with .returning() returned no first row, so a plain Error 'Failed to create rollback' is thrown (not a TRPCError — this service uses vanilla Errors). The transaction rolls back, so no rollback record or deployment linkage is persisted.","triggerScenarios":"The insert values (deploymentId, version, appName-derived fields) failing to produce a row — schema drift on the `rollbacks` table, a missing NOT NULL default, or malformed input after zod parsing of createRollbackSchema.","commonSituations":"Database migrations not applied after upgrading Dokploy (new columns like fullContext/image), or an API caller sending an incomplete payload.","solutions":["Apply pending migrations so the rollbacks table matches the drizzle schema","Validate the createRollback payload (deploymentId, version) before calling","Inspect server logs for the underlying postgres error during the insert"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const parsed = createRollbackSchema.safeParse(input);\nif (!parsed.success) throw new Error(parsed.error.message);","typeGuard":null,"tryCatchPattern":"try { await createRollback(input); } catch (e) { if (/Failed to create rollback/.test((e as Error).message)) { /* check migrations/logs */ } throw e; }","preventionTips":["Apply DB migrations on upgrade","Validate deploymentId/version in the payload"],"tags":["dokploy","rollback","drizzle","database-insert","transaction"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}