Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/update-pr-draft-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@github-tools/sdk': patch
---

Skip the REST update when `updatePullRequest` is called with only `draft`. Octokit was sending an empty PATCH body (`''`), which GitHub rejects with 400 before the GraphQL draft mutation could run.
5 changes: 4 additions & 1 deletion packages/github-tools/src/core/pull-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export const updatePullRequestDescription = 'Update a pull request — title, bo
/** Not idempotent — each call applies a new revision. */
export async function updatePullRequestCore({ token, owner, repo, pullNumber, title, body, state, base, draft }: { token: string, owner: string, repo: string, pullNumber: number, title?: string, body?: string, state?: 'open' | 'closed', base?: string, draft?: boolean }) {
const octokit = createOctokit(token)
const { data } = await octokit.rest.pulls.update({ owner, repo, pull_number: pullNumber, title, body, state, base })
const hasRestUpdate = title !== undefined || body !== undefined || state !== undefined || base !== undefined
const { data } = hasRestUpdate
? await octokit.rest.pulls.update({ owner, repo, pull_number: pullNumber, title, body, state, base })
: await octokit.rest.pulls.get({ owner, repo, pull_number: pullNumber })

if (draft !== undefined && draft !== data.draft) {
await octokit.graphql(draft ? CONVERT_TO_DRAFT_MUTATION : MARK_READY_FOR_REVIEW_MUTATION, { pullRequestId: data.node_id })
Expand Down
19 changes: 3 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ minimumReleaseAgeExclude:
overrides:
'@ai-sdk/vue>ai': 7.0.70
'@ai-sdk/workflow>ai': 7.0.70
'undici@5': 6.28.0

Loading