{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-github/src/client.rs","lineNumber":1137,"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":1119,"sourceCodeEnd":1155,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-github/src/client.rs#L1119-L1155","documentation":"but-github sent the enablePullRequestAutoMerge GraphQL mutation and GitHub answered, but the pullRequest.id field inside the payload was empty. As the module's own doc-comment explains, GitHub reports a refused mutation as a null field inside `data`, so an empty id means GitHub declined to enable auto-merge - not a transport failure.","triggerScenarios":"Calling enable-auto-merge on a pull request that is not open (draft, merged, closed); on a repo where 'Allow auto-merge' is disabled under Settings -> General -> Pull Requests; with a token lacking write access; or on a PR whose required checks have not been defined/passed so the mutation is refused.","commonSituations":"Auto-merge never enabled in repo settings; racing another user who merged or closed the PR; fine-grained PATs without Pull requests: write permission; GitHub Enterprise Server versions without auto-merge support.","solutions":["Confirm the PR is open and not a draft before enabling","Enable 'Allow auto-merge' in the repository's Settings -> General -> Pull Requests","Re-authenticate with an account that can write to the repository (`but config forge auth`)","Retry once the PR satisfies its branch-protection rules"],"exampleFix":"// before\nclient.enable_auto_merge_pull_request(&pr_id, &params).await?;\n\n// after\nlet pr = client.get_pull_request(owner, repo, number).await?;\nif pr.state == PrState::Open && !pr.is_draft {\n    client.enable_auto_merge_pull_request(&pr_id, &params).await?;\n} else {\n    anyhow::bail!(\"skip auto-merge: PR #{number} is not eligible\");\n}","handlingStrategy":"validation","validationCode":"let pr = client.get_pull_request(owner, repo, number).await?;\nif pr.state != PrState::Open || pr.is_draft {\n    anyhow::bail!(\"PR #{number} is not eligible for auto-merge\");\n}\n// optionally check repository.autoMergeAllowed via GraphQL before enabling","typeGuard":"fn ready_for_auto_merge(pr: &PullRequest) -> bool {\n    pr.state == PrState::Open && !pr.is_draft && !pr.auto_merge_enabled\n}","tryCatchPattern":"if let Err(e) = client.enable_auto_merge_pull_request(&pr_id, &params).await {\n    if e.to_string().contains(\"empty pull request id\") {\n        // GitHub refused the mutation: surface repo-settings hint instead of retrying\n        return Err(e.context(\"auto-merge refused - is 'Allow auto-merge' enabled in repo settings?\"));\n    }\n    return Err(e);\n}","preventionTips":["Enable 'Allow auto-merge' in repo settings before scripting it","Check PR state (open, non-draft) immediately before the mutation","Use a token with pull-request write access"],"tags":["github","graphql","pull-request","auto-merge","branch-protection"],"backgroundTag":"pull-request-auto-merge-unavailable","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}