Codeberg/Community
54
325
Fork
You've already forked Community
12

500 error when accessing pull request migrated from GitLab #1472

Open
opened 2024年02月06日 08:58:03 +01:00 by glts · 3 comments

Comment

I’ve just tried to migrate a repository from GitLab, but get a 500 error when I try to view the one migrated pull request.

https://codeberg.org/glts/indymilterbroken/pulls/ – shows the one PR

glts/indymilterbroken#1 – 500 error

There does not seem to be anything unusual about the original pull request.

Is there a way for me to fix this on my end? Can you help me fix it? Thank you.

### Comment I’ve just tried to migrate a repository from GitLab, but get a 500 error when I try to view the one migrated pull request. https://codeberg.org/glts/indymilterbroken/pulls/ – shows the one PR https://codeberg.org/glts/indymilterbroken/pulls/1 – 500 error There does not seem to be anything unusual about the [original pull request](https://gitlab.com/glts/indymilter/-/merge_requests/1). Is there a way for me to fix this on my end? Can you help me fix it? Thank you.
Owner
Copy link
GetRefCommitID, object does not exist [id: refs/pull/1/head, rel_path: ]
~~~ GetRefCommitID, object does not exist [id: refs/pull/1/head, rel_path: ] ~~~

Okay I was able to reproduce this locally. I'm not sure how to fix this yet (or what went wrong), but it boils down that when Forgejo clones the repository, it doesn't contain the PR's commit (as seen here) and therefor Forgejo is not able to point the refs/pull/1/head to any commit that is associated with the pull request. It's not a transient error and not really anything that can be fixed on your end for the time being, other than migrating the repository again but without migrating the merge requests.

Okay I was able to reproduce this locally. I'm not sure how to fix this yet (or what went wrong), but it boils down that when Forgejo clones the repository, it doesn't contain the [PR's commit](https://gitlab.com/glts/indymilter/-/commit/16bbe5cb42b26af74897f166c6ddb45be3fce110) (as [seen here](https://codeberg.org/glts/indymilterbroken/commit/16bbe5cb42b26af74897f166c6ddb45be3fce110)) and therefor Forgejo is not able to point the `refs/pull/1/head` to any commit that is associated with the pull request. It's not a transient error and not really anything that can be fixed on your end for the time being, other than migrating the repository again but without migrating the merge requests.

Okay this is confusing, I was able to figure out why Forgejo wasn't fetching the references. Forgejo doesn't receive enough information by the Gitlab API to fill in the details about the head and base repository.

CloneURL is incorrect, as WebURL in this case is https://gitlab.com/glts/indymilter/-/merge_requests/1 but the clone URL should be https://gitlab.com/daviessm/indymilter.git (but we don't know what the repository is of the PR). RepoName of Head is set to the repository name of where the PR is made against, not where it's from. OwnerName of Base is set to the author of the PR and not the owner of the repository where the PR is made against. Which leads to the issue that Forgejo cannot figure out if this PR is from a forked repository (in both cases the string is daviessm/indymilter) and if this was fixed, the CloneURL is still incorrect. Also for some reason the references of closed PRs aren't gathered which is an issue that also should be fixed. I wasn't able to confirm this, but it seems like the reference fetching itself also needs to be adjusted as Gitlab doesn't follow what Github does (for Github this works correctly).

Okay this is confusing, I was able to figure out why Forgejo wasn't fetching the references. Forgejo doesn't receive enough information by [the Gitlab API](https://docs.gitlab.com/ee/api/merge_requests.html#get-single-mr) to fill in the details about [the head and base repository](https://codeberg.org/forgejo/forgejo/src/commit/c6a89b490d93c776996c3318f911baa027f274fc/services/migrations/gitlab.go#L646-L658). `CloneURL` is incorrect, as `WebURL` in this case is `https://gitlab.com/glts/indymilter/-/merge_requests/1` but the clone URL should be `https://gitlab.com/daviessm/indymilter.git` (but we don't know what the repository is of the PR). `RepoName` of `Head` is set to the repository name of where the PR is made against, not where it's from. `OwnerName` of `Base` is set to the author of the PR and not the owner of the repository where the PR is made against. Which leads to the issue that Forgejo cannot figure out if this PR is [from a forked repository](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/modules/migration/pullrequest.go#L46-L49) (in both cases the string is `daviessm/indymilter`) and if this was fixed, the `CloneURL` is still incorrect. Also for some reason the references of [closed PRs aren't gathered](https://codeberg.org/forgejo/forgejo/src/commit/c6a89b490d93c776996c3318f911baa027f274fc/services/migrations/gitea_uploader.go#L586) which is an issue that also should be fixed. I wasn't able to confirm this, but it seems like the [reference fetching itself](https://codeberg.org/forgejo/forgejo/src/commit/c6a89b490d93c776996c3318f911baa027f274fc/services/migrations/gitea_uploader.go#L639-L642) also needs to be adjusted as Gitlab doesn't follow what Github does (for Github this works correctly).
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
accessibility

Reduces accessibility and is thus a "bug" for certain user groups on Codeberg.
bug

Something is not working the way it should. Does not concern outages.
bug
infrastructure

Errors evidently caused by infrastructure malfunctions or outages
Codeberg

This issue involves Codeberg's downstream modifications and settings and/or Codeberg's structures.
contributions welcome

Please join the discussion and consider contributing a PR!
docs

No bug, but an improvement to the docs or UI description will help
duplicate

This issue or pull request already exists
enhancement

New feature
infrastructure

Involves changes to the server setups, use `bug/infrastructure` for infrastructure-related user errors.
legal

An issue directly involving legal compliance
licence / ToS

involving questions about the ToS, especially licencing compliance
please chill
we are volunteers

Please consider editing your posts and remember that there is a human on the other side. We get that you are frustrated, but it's harder for us to help you this way.
public relations

Things related to Codeberg's external communication
question

More information is needed
question
user support

This issue contains a clearly stated problem. However, it is not clear whether we have to fix anything on Codeberg's end, but we're helping them fix it and/or find the cause.
s/Forgejo

Related to Forgejo. Please also check Forgejo's issue tracker.
s/Forgejo/migration

Migration related issues in Forgejo
s/Pages

Issues related to the Codeberg Pages feature
s/Weblate

Issue is related to the Weblate instance at https://translate.codeberg.org
s/Woodpecker

Woodpecker CI related issue
security

involves improvements to the sites security
service

Add a new service to the Codeberg ecosystem (instead of implementing into Gitea)
upstream

An open issue or pull request to an upstream repository to fix this issue (partially or completely) exists (i.e. Gitea, Forgejo, etc.)
wontfix

Codeberg's current set of contributors are not planning to spend time on delegating this issue.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#1472
Reference in a new issue
Codeberg/Community
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?