Skip to content

Pull request creation to forked repository via web api fails #20475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lixfel opened this issue Jul 25, 2022 · 2 comments · Fixed by #31863
Closed

Pull request creation to forked repository via web api fails #20475

lixfel opened this issue Jul 25, 2022 · 2 comments · Fixed by #31863
Labels

Comments

@lixfel
Copy link

lixfel commented Jul 25, 2022

Description

Gitea prevents pull request creation with the web api from the original repository to the fork with the error message: <Response [404]> b'{"errors":null,"message":"GetForkedRepo","url":"https://try.gitea.io/api/swagger"}\n'.

I managed to reproduce the issue on https://try.gitea.io/Lixfel/FreeSql .

Reproduction code:

token = "?"
import requests
response = requests.post(
        f'https://try.gitea.io/api/v1/repos/Lixfel/FreeSql/pulls?token={token}',
        json={
            "base": "master",
            "head": "huihuiyule:master",
            "title": "Update Upstream"
        })
print(f"{response} {response.content}")

Bug origin assumption:
https://github.com/go-gitea/gitea/blob/main/routers/api/v1/repo/pull.go#L967 seems to only allow PRs from the fork to the original repository, a method call GetForkingRepo is missing.

Gitea Version

1.16.9

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

https://gist.github.com/lixfel/e0c36e3b85a1b8ffbf994baf275e49bd

Screenshots

No response

Git Version

1:2.30.2-1 (apt version)

Operating System

Debian

How are you running Gitea?

Use of Gitea Downloads site; execution with systemd

Database

MySQL

@haru3me
Copy link

haru3me commented Sep 28, 2023

Since #26785, it become able to create PR to forked repository from origin via web.
But, I think the API still have the issue.

I've tested with try.gitea.io using this repository.
the result is below:

$ curl -X 'POST' \
>   'https://try.gitea.io/api/v1/repos/haru3me/test2/pulls?token=<secret>' \
>   -H 'accept: application/json' \
>   -H 'Content-Type: application/json' \
>   -d '{
>   "base": "main",
>   "body": "This is a PR",
>   "head": "lng2023:main",
>   "title": "PR title"
> }'
{"errors":null,"message":"GetForkedRepo","url":"https://try.gitea.io/api/swagger"}

On the my instance running 1.20.4 also have same issue.
additionally, I tested with tea command and also got fail.

.\tea.exe pr create --repo "haru/test_action_dummy" --head "dummy:main" --base "main"
Error: could not create PR from dummy:main to haru:main: GetForkedRepo

By the way, I know #20479 is closed recently. Is there any plan with this ..?
I think it would be really helpful with Gitea Actions.

@LordChunk
Copy link
Contributor

I'm also running into the exaqct issue on v1.22.1

lunny pushed a commit to lunny/gitea that referenced this issue Nov 21, 2024
lunny added a commit that referenced this issue Nov 22, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 2, 2025
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this issue Jan 23, 2025
Resolves go-gitea#20475

(cherry picked from commit 7e68bc8)

Conflicts:
	tests/integration/pull_create_test.go
  add missing testPullCreateDirectly from
  c63060b Fix code owners will not be mentioned when a pull request comes from a forked repository (go-gitea#30476)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants