Forgejo and Gitea: why the pull request was not created
Creating a pull request through the API (POST /api/v1/repos/OWNER/REPO/pulls with head, base and title) is refused with 409, 422, 404 or 403. All of this is from the source of both (CreatePullRequest and parseCompareInfo in routers/api/v1/repo/pull.go, and NewPullRequest in services/pull/pull.go), read on October 24, 2026.
The answers
- 409
pull request already exists for these targets [id: 123, issue_id: 7, head_repo_id: 1, base_repo_id: 1, head_branch: feature, base_branch: main]: a pull request from the same branch of the same repository into the same base branch is still open. Despite its name,issue_idis that pull request's number (#7 here);idis an internal ID. One that is closed or merged does not count, and the same branch into a different base branch is allowed. - 422
Invalid PullRequest: There are no changes between the head and the base:headandbaseare the same. In the source, this compares only the two names as you wrote them. - 422
Invalid PullRequest: base and head must be branches(Gitea): one of them is a tag or a commit. - 404
The target couldn't be found.: a branch is not on the server, usually because it has not been pushed yet. Forgejo adds the reason inerrors, such ascould not find 'feature' to be a commit, branch or tag in the head repository OWNER/REPO; Gitea gives none. For a pull request from a fork,headis writtenOWNER:branch, and Forgejo saysthe owner … does not existor that the ownerdoes not have a fork ofthe repository. - 403
user must be a collaborator(Gitea): you are not a collaborator of the repository, nor a member of its organization with access to its code, and you may not write to the repository the branch comes from either. Forgejo's source has no such check. - 403 when the repository's owner has blocked you, on both.
A token without permission to write to repositories is refused with 403 too, but that answer says token does not have at least one of required scope(s); see which permission to add. A repository that does not exist, or that you cannot see, answers 404 as well; see missing, private or renamed.
Where it stands
curl -H "Authorization: token your-token" https://codeberg.org/api/v1/repos/OWNER/REPO/pulls/main/feature
This answers a pull request from feature into main, or 404 when there has never been one. In the source it does not pick only open ones, so look at state and number: the open one is the one the 409 means. To see whether the server has the branch, …/repos/OWNER/REPO/branches/feature answers 404 when it does not. Use your own server's address instead of codeberg.org.
What to do
- 409: open the pull request whose number is
issue_idand keep working there: pushing to the branch updates it. If you want a new one, close the old one first, or choose another base branch. - 422 "no changes": choose a different base branch, usually the default branch.
- 404: push the branch (
git push -u origin feature), then create the pull request; from a fork, write the head asOWNER:branch. - 403 "user must be a collaborator": ask to be added as a collaborator, or fork the repository and create the pull request from your fork.
Forgejo and Gitea pull requests in IntelliJ IDEA
Pull Request Inbox for Forgejo and Gitea, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, creates a pull request from the branch you are on. When the server does not have the branch yet, it offers to push it first; it does not accept the same branch as the target; and when the server answers 409, it says that a pull request for this branch is already open, with the server's words. For 403, it says that your permissions in the repository or its branch protection may not let your account do it, with the server's words; other refusals in the server's words. Reading is free; creating, approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).
Forgejo, Gitea and Codeberg are names of their respective owners; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by the Forgejo project, Codeberg e.V., the Gitea project or JetBrains.
More: Forgejo and Gitea merge refused (405, 409) · Forgejo and Gitea review refused (422) · Forgejo and Gitea branch update refused (403, 409, 422) · "token does not have at least one of required scope(s)" · 401 "token is required" and unknown tokens · 404 "The target couldn't be found." and "not found" · Forgejo and Gitea comment refused (403, 422, 400) · Forgejo and Gitea search refused (400, 422) · Forgejo and Gitea pull request files (pages of 50, changed_files) · Forgejo and Gitea pull request plugins for IntelliJ IDEA, compared · 日本語