{"record":{"id":"b40accfd62d78703","repo":"coollabsio/coolify","slug":"69420","errorCode":"69420","errorMessage":"Deployment cancelled by user","messagePattern":"Deployment cancelled by user","errorType":"exception","errorClass":"DeploymentException","httpStatus":null,"severity":"info","filePath":"app/Jobs/ApplicationDeploymentJob.php","lineNumber":4845,"sourceCode":"            );\n        } catch (Exception $e) {\n            $post_deployment_command_output = $this->saved_outputs->get('post-deployment-command-output');\n            if ($post_deployment_command_output) {\n                $this->application_deployment_queue->addLogEntry('Post-deployment command failed.');\n                $this->application_deployment_queue->addLogEntry($post_deployment_command_output, 'stderr');\n            }\n        }\n    }\n\n    /**\n     * Check if the deployment was cancelled and abort if it was\n     */\n    private function checkForCancellation(): void\n    {\n        $this->application_deployment_queue->refresh();\n        if ($this->application_deployment_queue->status === ApplicationDeploymentStatus::CANCELLED_BY_USER->value) {\n            $this->application_deployment_queue->addLogEntry('Deployment cancelled by user, stopping execution.');\n            throw new DeploymentException('Deployment cancelled by user', 69420);\n        }\n    }\n\n    /**\n     * Transition deployment to a new status with proper validation and side effects.\n     * This is the single source of truth for status transitions.\n     */\n    private function transitionToStatus(ApplicationDeploymentStatus $status): void\n    {\n        if ($this->isInTerminalState()) {\n            return;\n        }\n\n        $this->updateDeploymentStatus($status);\n        $this->handleStatusTransition($status);\n        queue_next_deployment($this->application);\n    }\n","sourceCodeStart":4827,"sourceCodeEnd":4863,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Jobs/ApplicationDeploymentJob.php#L4827-L4863","documentation":"ApplicationDeploymentJob::checkForCancellation() refreshes the application_deployment_queue row and throws DeploymentException with sentinel code 69420 the moment its status is CANCELLED_BY_USER. This is Coolify's cooperative-cancellation mechanism: the UI/API sets the row status, and the job notices it at checkpoints between deployment steps and aborts.","triggerScenarios":"A user clicks 'Cancel' on an in-flight deployment; an API client PATCHes the deployment queue status to cancelled_by_user; deployment automation supersedes an older run by cancelling it.","commonSituations":"Long builds cancelled mid-way through build/deploy phases; scripts that cancel rolling deployments before retrying; multiple team members racing on the same application.","solutions":["No fix needed — this is an intentional abort, not a malfunction; confirm in the deployment screen that cancellation was requested.","If deployments show cancelled with nobody clicking Cancel, audit what sets status CANCELLED_BY_USER (API tokens, webhooks, other admins).","Custom orchestration code must compare getCode() === 69420 before treating this as a failure worth alerting or retrying."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { $job->handle(); } catch (DeploymentException $e) { if ((int) $e->getCode() === 69420) { // user-initiated cancel: mark as cancelled, skip alerting/retry return; } throw $e; }","preventionTips":["Treat exit code 69420 as control flow, not failure — exclude it from alerting and retry policies.","Add cancellation checkpoints in custom long-running deployment steps by calling the existing checkForCancellation-style refresh.","Reduce surprise cancellations by locking concurrent deploys of the same application."],"tags":["deployment","cancellation","coolify"],"backgroundTag":"operation-cancelled","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}