{"record":{"id":"2fff9ad53b0f8bb2","repo":"gitbutlerapp/gitbutler","slug":"github-graphql-disablepullrequestautomerge-returne","errorCode":null,"errorMessage":"GitHub GraphQL disablePullRequestAutoMerge returned an empty pull request id","messagePattern":"GitHub GraphQL disablePullRequestAutoMerge returned an empty pull request id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-github/src/client.rs","lineNumber":1728,"sourceCode":"        }\n\n        #[derive(Deserialize)]\n        struct MutationData {\n            #[serde(rename = \"disablePullRequestAutoMerge\")]\n            disable_pull_request_auto_merge: MutationPayload,\n        }\n\n        let data: MutationData = self\n            .graphql_query(GQL_DISABLE_PR_AUTO_MERGE, &Variables { pull_request_id })\n            .await?;\n\n        if data\n            .disable_pull_request_auto_merge\n            .pull_request\n            .id\n            .is_empty()\n        {\n            bail!(\"GitHub GraphQL disablePullRequestAutoMerge returned an empty pull request id\");\n        }\n\n        Ok(())\n    }\n\n    async fn get_pull_request_node_id(\n        &self,\n        owner: &str,\n        repo: &str,\n        pr_number: i64,\n    ) -> Result<PullRequestNodeId> {\n        #[derive(Serialize)]\n        struct Variables<'a> {\n            owner: &'a str,\n            repo: &'a str,\n            number: i64,\n        }\n","sourceCodeStart":1710,"sourceCodeEnd":1746,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-github/src/client.rs#L1710-L1746","documentation":"Mirror of the enable case: the GraphQL disablePullRequestAutoMerge mutation returned a payload whose pull request id is empty, so the client cannot confirm that auto-merge was actually disabled for the PR and reports the ambiguous result as an error.","triggerScenarios":"Calling disable auto-merge when no auto-merge request exists on the PR (mutation is effectively a no-op) or the response payload is missing the node id due to API/schema behavior.","commonSituations":"Race conditions where GitHub already merged the PR before disabling auto-merge; callers disabling auto-merge on PRs that never had it enabled; concurrent automations toggling the same PR.","solutions":["Check pull_request.auto_merge_request exists before calling the disable mutation","Handle races gracefully: refetch the PR state and treat 'already merged' as success","Inspect the raw GraphQL response for a top-level errors array explaining the empty payload"],"exampleFix":"// before\nclient.disable_pull_request_auto_merge(&params).await?;\n// after\nif pr.auto_merge_request.is_none() {\n    return Ok(()); // nothing to disable\n}\nclient.disable_pull_request_auto_merge(&params).await?;","handlingStrategy":"validation","validationCode":"// only disable when auto-merge is active\nif pr.auto_merge_request.is_none() { return Ok(()); }","typeGuard":null,"tryCatchPattern":"match client.disable_pull_request_auto_merge(&params).await {\n    Err(e) if e.to_string().contains(\"empty pull request id\") => {\n        // auto-merge may already be gone or the PR merged; refetch before failing\n        let pr = client.get_pull_request(owner, repo, pr_number).await?;\n        if pr.auto_merge_request.is_none() || pr.merged { Ok(()) } else { Err(e) }\n    }\n    other => other,\n}","preventionTips":["Check auto_merge_request before disabling","Handle the merged-PR race as success","Avoid concurrent automations toggling auto-merge on the same PR","Refetch PR state after ambiguous mutation failures"],"tags":["github","graphql","auto-merge","pull-request"],"backgroundTag":"empty-required-field","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"}