Wrong URL when importing from GitLab hosted in subdirectory #6305

Closed
opened 2025-11-02 06:51:40 -06:00 by GiteaMirror · 18 comments
Owner

Originally created by @pat-s on GitHub (Nov 12, 2020).

Gitea v1.13.0-rc2

Note that in the GET request gitlab/ is missing after the domain name.

(not sure if the error message is related to this though)

Migrating from http://my.gitlab.domain/gitlab/user/test.git failed.

GET https://my.gitlab.domain/api/v4/projects/gitlab/user/test: 502 failed to parse unknown error format
Originally created by @pat-s on GitHub (Nov 12, 2020). Gitea v1.13.0-rc2 Note that in the `GET` request `gitlab/` is missing after the domain name. (not sure if the error message is related to this though) ``` Migrating from http://my.gitlab.domain/gitlab/user/test.git failed. GET https://my.gitlab.domain/api/v4/projects/gitlab/user/test: 502 failed to parse unknown error format ```
GiteaMirror added the topic/repo-migrationtype/bug labels 2025-11-02 06:51:40 -06:00
Author
Owner

@lafriks commented on GitHub (Nov 14, 2020):

How does url for subgroup repository does look like in such case?

@lafriks commented on GitHub (Nov 14, 2020): How does url for subgroup repository does look like in such case?
Author
Owner

@6543 commented on GitHub (Nov 14, 2020):

since gitlab has namespaces, the migration tool cant difference by url if it is a subdirectory or namespace ...

d130cd147f/modules/migrations/gitlab.go (L44-L46)

so we either have to walk throu the path and test if it works ... or add a subdirectory option ...

idear:

if len(strings.split(path,"/")) > 2,
    then test if you can get gitlab-version ...
        if not add first part of path to baseUrl,
        repeat until repoPath == 2,
            if it still fails -> error no gitlab detected 

this should go before d130cd147f/modules/migrations/gitlab.go (L90)

@6543 commented on GitHub (Nov 14, 2020): since gitlab has namespaces, the migration tool cant difference by url if it is a subdirectory or namespace ... https://github.com/go-gitea/gitea/blob/d130cd147f24eb222a539a5b262d166f94aad5fa/modules/migrations/gitlab.go#L44-L46 so we either have to walk throu the path and test if it works ... or add a subdirectory option ... ## idear: ``` if len(strings.split(path,"/")) > 2, then test if you can get gitlab-version ... if not add first part of path to baseUrl, repeat until repoPath == 2, if it still fails -> error no gitlab detected ``` this should go before https://github.com/go-gitea/gitea/blob/d130cd147f24eb222a539a5b262d166f94aad5fa/modules/migrations/gitlab.go#L90
Author
Owner

@6543 commented on GitHub (Nov 14, 2020):

@pat-s are you able to test #13563 ?

@6543 commented on GitHub (Nov 14, 2020): @pat-s are you able to test #13563 ?
Author
Owner

@pat-s commented on GitHub (Nov 14, 2020):

If there is a docker image being created for this branch yes, otherwise no. I can test once its merged into master.

@pat-s commented on GitHub (Nov 14, 2020): If there is a docker image being created for this branch yes, otherwise no. I can test once its merged into master.
Author
Owner

@6543 commented on GitHub (Nov 14, 2020):

@pat-s are you allowed to send me temporary read access token & url to my email so I can test?

Mail: “6543[a-t]obermui.de” PGP Key (A1CA74D27FD13271)

@6543 commented on GitHub (Nov 14, 2020): @pat-s are you allowed to send me temporary read access token & url to my email so I can test? `Mail: “6543[a-t]obermui.de” PGP Key (A1CA74D27FD13271)`
Author
Owner

@pat-s commented on GitHub (Nov 14, 2020):

This won't work, neither time nor permission wise I guess.

Happy to test once its in master then. Thanks for your work!

@pat-s commented on GitHub (Nov 14, 2020): This won't work, neither time nor permission wise I guess. Happy to test once its in master then. Thanks for your work!
Author
Owner

@6543 commented on GitHub (Nov 16, 2020):

@pat-s It's in master - would be nice if you can verify it :)

@6543 commented on GitHub (Nov 16, 2020): @pat-s It's in master - would be nice if you can verify it :)
Author
Owner

@pat-s commented on GitHub (Nov 18, 2020):

Pulled the latest master (Gitea Version: 1.14.0+dev-233-g0615b668d) and now I get

Invalid csrf token.

when hitting the migrate button.

I double-checked that the token is valid.

No errors in the logs.

@pat-s commented on GitHub (Nov 18, 2020): Pulled the latest master (Gitea Version: 1.14.0+dev-233-g0615b668d) and now I get ``` Invalid csrf token. ``` when hitting the migrate button. I double-checked that the token is valid. No errors in the logs.
Author
Owner

@6543 commented on GitHub (Nov 18, 2020):

@pat-s pleace clear the cache

@6543 commented on GitHub (Nov 18, 2020): @pat-s pleace clear the cache
Author
Owner

@pat-s commented on GitHub (Nov 18, 2020):

Helped. Still getting the same error as described though.

Could it be an issue with our nginx config and some rewrite rules that might not work as expected with respect to GitLabs API endpoint?

@pat-s commented on GitHub (Nov 18, 2020): Helped. Still getting the same error as described though. Could it be an issue with our nginx config and some rewrite rules that might not work as expected with respect to GitLabs API endpoint?
Author
Owner

@6543 commented on GitHub (Nov 18, 2020):

@pat-s are you on discord - so we dont spam others email box too mouch?

Does it still show "invalid csrf token" or another error?

@6543 commented on GitHub (Nov 18, 2020): @pat-s are you on discord - so we dont spam others email box too mouch? Does it still show "invalid csrf token" or another error?
Author
Owner

@pat-s commented on GitHub (Nov 18, 2020):

Whom are we spamming? AFAICS all of this contributes to this issue.

Just joined the discord server.

@pat-s commented on GitHub (Nov 18, 2020): Whom are we spamming? AFAICS all of this contributes to this issue. Just joined the discord server.
Author
Owner

@6543 commented on GitHub (Nov 18, 2020):

tested with: https://play.golang.org/p/NnK3Xhabn2s that this issue is still here :/

@6543 commented on GitHub (Nov 18, 2020): tested with: https://play.golang.org/p/NnK3Xhabn2s that this issue is still here :/
Author
Owner

@pat-s commented on GitHub (Nov 19, 2020):

With 1.14.0+dev-239-gad2a28862 as of this morning I am still facing the issue :/

@pat-s commented on GitHub (Nov 19, 2020): With `1.14.0+dev-239-gad2a28862` as of this morning I am still facing the issue :/
Author
Owner

@6543 commented on GitHub (Nov 19, 2020):

@pat-s this time I tested it sucessfully with https://gitlab.pr.gitea.io/gitlab/awesomegroup/supgr1/subsubgr/totalchaos.git

but can you test https://play.golang.org/p/mvuSegdaSm5 localy with your own repo and tell me the outcome?

@6543 commented on GitHub (Nov 19, 2020): @pat-s this time I tested it sucessfully with `https://gitlab.pr.gitea.io/gitlab/awesomegroup/supgr1/subsubgr/totalchaos.git` but can you test https://play.golang.org/p/mvuSegdaSm5 localy with your own repo and tell me the outcome?
Author
Owner

@pat-s commented on GitHub (Nov 19, 2020):

GL returned:
error: '<nil>'
version: '<nil>'
new base: 'http://DOMAIN/gitlab'
new repoPath: 'patrick/cynkra-test'
this error should not happen(2):
Get "http://DOMAIN/api/v4/version": dial tcp: lookup DOMAIN on 169.254.169.254:53: dial udp 169.254.169.254:53: connect: no route to host

tested in the go playground

Running locally I get

GL returned:
error: '<nil>'
version: '<nil>'
new base: 'http://DOMAIN/gitlab'
new repoPath: 'patrick/cynkra-test'
this error should not happen(2):
GET https://DOMAIN/api/v4/version: 502 failed to parse unknown error format
@pat-s commented on GitHub (Nov 19, 2020): ``` GL returned: error: '<nil>' version: '<nil>' new base: 'http://DOMAIN/gitlab' new repoPath: 'patrick/cynkra-test' this error should not happen(2): Get "http://DOMAIN/api/v4/version": dial tcp: lookup DOMAIN on 169.254.169.254:53: dial udp 169.254.169.254:53: connect: no route to host ``` tested in the go playground Running locally I get ``` GL returned: error: '<nil>' version: '<nil>' new base: 'http://DOMAIN/gitlab' new repoPath: 'patrick/cynkra-test' this error should not happen(2): GET https://DOMAIN/api/v4/version: 502 failed to parse unknown error format ```
Author
Owner

@6543 commented on GitHub (Nov 19, 2020):

@pat-s https://play.golang.org/p/QKFBmIZxZpC ... we get there ...

@6543 commented on GitHub (Nov 19, 2020): @pat-s https://play.golang.org/p/QKFBmIZxZpC ... we get there ...
Author
Owner

@pat-s commented on GitHub (Nov 19, 2020):

GL returned:
error: '<nil>'
version: '<nil>'
new base: 'http://DOMAIN/gitlab'
new repoPath: 'patrick/cynkra-test'
GL returned:
error: 'GET https://DOMAIN/api/v4/version: 502 failed to parse unknown error format'
version: 'gitlab.Version{Version:"13.5.3-ee", Revision:"b9d194b6b91"}'break
SUCESS!

BaseURL: 'http://DOMAIN/gitlab'
RepoPath: 'patrick/cynkra-test'
@pat-s commented on GitHub (Nov 19, 2020): ``` GL returned: error: '<nil>' version: '<nil>' new base: 'http://DOMAIN/gitlab' new repoPath: 'patrick/cynkra-test' GL returned: error: 'GET https://DOMAIN/api/v4/version: 502 failed to parse unknown error format' version: 'gitlab.Version{Version:"13.5.3-ee", Revision:"b9d194b6b91"}'break SUCESS! BaseURL: 'http://DOMAIN/gitlab' RepoPath: 'patrick/cynkra-test' ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6305