Skip to content
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

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

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

a1012112796 added a commit to a1012112796/gitea that referenced this issue Nov 27, 2022
fix go-gitea#20475

Signed-off-by: a1012112796 <1012112796@qq.com>
@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants