{"record":{"id":"6130f2f1b1cdfe36","repo":"gitbutlerapp/gitbutler","slug":"failed-to-disable-merge-request-auto-merge-statu","errorCode":null,"errorMessage":"Failed to disable merge request auto-merge: {status} - {error_text}","messagePattern":"Failed to disable merge request auto-merge: (.+?) - (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-gitlab/src/client.rs","lineNumber":582,"sourceCode":"                let status = response.status();\n                let error_text = response.text().await.unwrap_or_default();\n                bail!(\"Failed to enable merge request auto-merge: {status} - {error_text}\");\n            }\n\n            return Ok(());\n        }\n\n        let url = format!(\n            \"{}/projects/{}/merge_requests/{}/cancel_merge_when_pipeline_succeeds\",\n            self.base_url, project_id, params.mr_iid\n        );\n\n        let response = self.client.post(&url).send().await?;\n\n        if !response.status().is_success() {\n            let status = response.status();\n            let error_text = response.text().await.unwrap_or_default();\n            bail!(\"Failed to disable merge request auto-merge: {status} - {error_text}\");\n        }\n\n        Ok(())\n    }\n\n    pub async fn fetch_project(&self, project_id: GitLabProjectId) -> Result<GitLabProject> {\n        self.fetch_project_by_path(project_id.to_string()).await\n    }\n\n    pub async fn fetch_project_by_numeric_id(&self, project_id: i64) -> Result<GitLabProject> {\n        self.fetch_project_by_path(project_id.to_string()).await\n    }\n\n    async fn fetch_project_by_path(&self, project_id: String) -> Result<GitLabProject> {\n        #[derive(Deserialize)]\n        struct GitLabApiProject {\n            id: i64,\n            path_with_namespace: String,","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-gitlab/src/client.rs#L564-L600","documentation":"This is the disable branch of set_merge_request_auto_merge: it POSTs to the auto-merge cancel/delete endpoint and bails on any non-2xx response, including status and GitLab's error body. Most commonly this fires when no auto-merge is actually set on the MR (GitLab returns 404) or the MR is already merged.","triggerScenarios":"Calling the disable path when the MR has no pending auto-merge record (404 from GitLab), when the MR was already merged or closed, with an unauthorized token (401/403), or against a GitLab version lacking the endpoint.","commonSituations":"Race where auto-merge completed (MR merged) between enabling and disabling, so the cancel endpoint 404s; cleanup code running after a successful merge; switching auto-merge strategies by disable-then-enable where the disable hits a 404.","solutions":["Treat 404 as a benign case: the auto-merge is already gone (merged or cancelled) — ignore instead of failing.","Check the MR state (`state == \"merged\"`) before attempting to disable and skip the call if already merged.","For 401/403 verify token scopes and project permissions as with other MR endpoints.","Retry 429/5xx responses with backoff; they are transient."],"exampleFix":"// before\nclient.set_merge_request_auto_merge_disable(project_id, iid).await?;\n// after\nif let Err(e) = client.set_merge_request_auto_merge_disable(project_id, iid).await {\n    let msg = e.to_string();\n    if !msg.contains(\"404\") {\n        return Err(e); // 404 = auto-merge already gone, safe to ignore\n    }\n}","handlingStrategy":"fallback","validationCode":"let mr = client.get_merge_request(project_id, mr_iid).await?;\nif mr.state != \"opened\" {\n    // nothing to disable on merged/closed MRs\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.disable_auto_merge(project_id, iid).await {\n    let msg = e.to_string();\n    if msg.contains(\"404\") || msg.contains(\"405\") {\n        // no active auto-merge: treat as success\n    } else {\n        return Err(e);\n    }\n}","preventionTips":["Treat 404 from the cancel endpoint as 'already gone', not a failure","Skip disabling when MR state is merged or closed","Keep a local flag of whether you enabled auto-merge to avoid redundant cancels","Retry 429/5xx with backoff"],"tags":["gitlab","auto-merge","http-error","merge-request"],"backgroundTag":"http-error-response","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}