gitbutlerapp/gitbutler · error
GitHub GraphQL convertPullRequestToDraft returned an empty…
Error message
GitHub GraphQL convertPullRequestToDraft returned an empty pull request id
What it means
The convertPullRequestToDraft GraphQL mutation returned successfully but with an empty pull_request.id in the response. The library requires the node id to consider the operation confirmed and bails otherwise.
Solutions
- Skip the call when the PR is already a draft (check state == 'draft' beforehand)
- Inspect the raw GraphQL response to confirm whether the id is truly absent
- Confirm the authenticated token has write access to the repository
- Check the GitHub GraphQL schema/changelog for renames affecting the queried fields
Example fix
// before
client.set_pull_request_draft_state(¶ms).await?;
// after
if pr.is_draft {
return Ok(()); // already a draft, nothing to do
}
client.set_pull_request_draft_state(¶ms).await?; Defensive patterns
Strategy: validation
Validate before calling
// skip when already a draft
if pr.is_draft { return Ok(()); } Try / catch
match client.set_pull_request_draft_state(¶ms).await {
Err(e) if e.to_string().contains("empty pull request id") => {
// refetch and verify whether the conversion actually happened
let pr = client.get_pull_request(owner, repo, pr_number).await?;
if pr.is_draft { Ok(()) } else { Err(e) }
}
other => other,
} Prevention
- Check is_draft before converting
- Verify token write access on the target repo/fork
- Confirm the mutation payload with gh api graphql on failure
- Watch the GitHub GraphQL changelog for schema changes
When it happens
Trigger: Calling set_pull_request_to_draft / convert_pull_request_to_draft when the mutation response lacks the PR node id — often because the PR is already a draft (no-op) or the GraphQL response shape is not what the client's query expects.
Common situations: Automations converting already-draft PRs; head branches from forks with restricted permissions; GitHub GraphQL schema changes.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- GitHub GraphQL disablePullRequestAutoMerge returned an…
- GitHub GraphQL enablePullRequestAutoMerge returned an empty…
- GitHub GraphQL markPullRequestReadyForReview returned an…
- GitHub GraphQL pull request
- Could not update all PR targets before native stack…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/d9828cedaa2cd955.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-github/src/client.rs:1595
pull_request: GraphQlPullRequest,
}
#[derive(Deserialize)]
struct GraphQlPullRequest {
id: String,
}
let data: MutationData = self
.graphql_query(GQL_SET_PR_DRAFT, &Variables { pull_request_id })
.await?;
if data
.convert_pull_request_to_draft
.pull_request
.id
.is_empty()
{
bail!("GitHub GraphQL convertPullRequestToDraft returned an empty pull request id");
}
Ok(())
}
/// Enable or disable a PR's auto-merge.
pub async fn set_pull_request_auto_merge(
&self,
params: &SetPullRequestAutoMergeParams<'_>,
) -> Result<()> {
let pull_request_id = self
.get_pull_request_node_id(params.owner, params.repo, params.pr_number)
.await?;
match ¶ms.state {
AutoMergeState::Disabled => {
self.disable_auto_merge_pull_request(&pull_request_id).await
}View on GitHub (pinned to 58e5313667)