Skip to content

Closing pull request result in code 422- "Cannot change the base branch of a closed pull request" #3456

Closed
@MarcinGinszt

Description

@MarcinGinszt

Steps to reproduce:

prs, _, _ := client.PullRequests.List(ctx, owner, repo, nil)
pull := prs[0]
pull.State = github.String("closed")
// pull.Base = nil  <- if this line is added, error does not appear
_, _, err := client.PullRequests.Edit(ctx, owner, repo, *pull.Number, pull)
require.NoError(t, err)

This code successfully closes the PR, but results in error:

received unexpected error:
PATCH https://api.github.com/repos/owner/repo/pulls/1: 422 Validation Failed [{Resource:PullRequest Field:base Code:invalid Message:Cannot change the base branch of a closed pull request.}]

Is that expected behaviour? Do I use the library correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions