{"record":{"id":"0f9c0f9b4a1beb67","repo":"Dokploy/dokploy","slug":"deployment-not-found","errorCode":null,"errorMessage":"Deployment not found","messagePattern":"Deployment not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/services/rollbacks.ts","lineNumber":53,"sourceCode":"\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\n\t\tconst registry = rest.registryId\n\t\t\t? await findRegistryByIdWithCredentials(rest.registryId)\n\t\t\t: rest.registry;\n\t\tconst buildRegistry = rest.buildRegistryId\n\t\t\t? await findRegistryByIdWithCredentials(rest.buildRegistryId)\n\t\t\t: rest.buildRegistry;\n\t\tconst rollbackRegistry = rest.rollbackRegistryId","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/rollbacks.ts#L35-L71","documentation":"createRollback loads the deployment referenced by rollback.deploymentId via findDeploymentById; if it does not exist or lacks an applicationId, a plain Error 'Deployment not found' aborts the transaction. The rollback needs the deployment to snapshot the application's full config (registries, sources) into fullContext.","triggerScenarios":"Creating a rollback for a deploymentId that was deleted, belongs to a different app, or is a dangling FK after manual DB edits or partial cleanup.","commonSituations":"Old deployments purged by retention cleanup while the UI still offers rollback; DB rows removed manually; deployment record created outside normal flow.","solutions":["Verify the deployment still exists and belongs to the intended application before creating the rollback","Re-deploy the application to generate a fresh deployment, then create the rollback from it","If rows were deleted manually, repair dangling references in the rollbacks table"],"exampleFix":"// before\nconst deployment = await findDeploymentById(rollback.deploymentId);\nif (!deployment?.applicationId) throw new Error(\"Deployment not found\");\n\n// after\nconst deployment = await findDeploymentById(rollback.deploymentId).catch(() => null);\nif (!deployment?.applicationId) {\n  throw new Error(`Deployment ${rollback.deploymentId} not found; redeploy the app first`);\n}","handlingStrategy":"try-catch","validationCode":"const dep = await findDeploymentById(deploymentId).catch(() => null);\nif (!dep?.applicationId) throw new Error(`Deployment ${deploymentId} missing; cannot snapshot`);","typeGuard":"const hasApplication = (d: unknown): d is { applicationId: string } =>\n  typeof d === \"object\" && d !== null && typeof (d as any).applicationId === \"string\";","tryCatchPattern":"try { await createRollback(input); } catch (e) { if (/Deployment not found/.test((e as Error).message)) { /* redeploy then retry */ } throw e; }","preventionTips":["Create rollbacks only from deployments you just verified exist","Exclude rollback-referenced deployments from aggressive retention cleanup"],"tags":["dokploy","rollback","deployment","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}