{"record":{"id":"d20ece4bc0c13766","repo":"gitbutlerapp/gitbutler","slug":"github-graphql-enablepullrequestautomerge-returned","errorCode":null,"errorMessage":"GitHub GraphQL enablePullRequestAutoMerge returned an empty pull request id","messagePattern":"GitHub GraphQL enablePullRequestAutoMerge returned an empty pull request id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-github/src/client.rs","lineNumber":1685,"sourceCode":"                    input: EnablePullRequestAutoMergeInput {\n                        pull_request_id,\n                        merge_method: params.merge_method.as_ref().map(Into::into),\n                        expected_head_oid: params.expected_head_oid,\n                        commit_headline: params.commit_headline,\n                        commit_body: params.commit_body,\n                        author_email: params.author_email,\n                    },\n                },\n            )\n            .await?;\n\n        if data\n            .enable_pull_request_auto_merge\n            .pull_request\n            .id\n            .is_empty()\n        {\n            bail!(\"GitHub GraphQL enablePullRequestAutoMerge returned an empty pull request id\");\n        }\n\n        Ok(())\n    }\n\n    async fn disable_auto_merge_pull_request(\n        &self,\n        pull_request_id: &PullRequestNodeId,\n    ) -> Result<()> {\n        #[derive(Deserialize)]\n        struct MutationPayload {\n            #[serde(rename = \"pullRequest\")]\n            pull_request: GraphQlPullRequest,\n        }\n\n        #[derive(Deserialize)]\n        struct GraphQlPullRequest {\n            id: String,","sourceCodeStart":1667,"sourceCodeEnd":1703,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-github/src/client.rs#L1667-L1703","documentation":"The GraphQL enablePullRequestAutoMerge mutation completed, but the returned payload's pull request id was empty. GitHub acknowledged the mutation without yielding a usable PR node, which the client treats as a failed or ambiguous enable-auto-merge rather than assuming success.","triggerScenarios":"Calling enable auto-merge when the response contains no node id: the PR may not satisfy auto-merge preconditions (branch protection without required checks configured), auto-merge may already be enabled, or the repo/plan doesn't support it.","commonSituations":"Enabling auto-merge on repos without branch protection rules (GitHub rejects or returns unusable payloads); PR already queued for auto-merge; free-plan repos where auto-merge is unavailable.","solutions":["Ensure the repository has branch protection with required status checks — auto-merge requires them","Check whether auto-merge is already enabled on the PR and skip the call","Verify repository plan/settings allow auto-merge (repo setting 'Allow auto-merge' must be on)","Query the raw mutation via gh api graphql to see whether an errors array accompanies the empty id"],"exampleFix":"// before\nclient.enable_pull_request_auto_merge(&params).await?;\n// after\nif pr.auto_merge_request.is_some() {\n    return Ok(()); // auto-merge already enabled\n}\nclient.enable_pull_request_auto_merge(&params).await?;","handlingStrategy":"validation","validationCode":"// auto-merge requires branch protection with required checks; and must not already be set\nif pr.auto_merge_request.is_some() { return Ok(()); }\nif !repo_has_required_checks(owner, repo) { return Err(anyhow!(\"auto-merge needs required status checks\")); }","typeGuard":null,"tryCatchPattern":"match client.enable_pull_request_auto_merge(&params).await {\n    Err(e) if e.to_string().contains(\"empty pull request id\") => {\n        // check whether auto-merge actually got enabled despite the empty id\n        let pr = client.get_pull_request(owner, repo, pr_number).await?;\n        if pr.auto_merge_request.is_some() { Ok(()) } else { Err(e) }\n    }\n    other => other,\n}","preventionTips":["Enable 'Allow auto-merge' and required status checks in repo settings first","Skip the call when auto-merge is already enabled","Confirm repo plan supports auto-merge","Inspect the GraphQL errors array when the node id comes back empty"],"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"}