You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I first thought it's because of the API limit in Gitlab or because one or two projects are archived, but I figured out that it also fails to sync sometimes "some-connection1" and "some-connection2" and furthermore, the 8 repositories are always other repos - not the same. Any ideas why the indexing fails?
Hey Tim, sorry you're hitting this. Since the specific repos that are failing is changing I suspect this might be a networking issue when cloning the repos (I'm assuming the fail is happening during cloning not indexing from your error log). We've hit this before in certain environments where the networking is limited.
sourcebot-1 | [backend] | 2025-05-10T05:19:47.283Z error: [RepoManager] Failed to sync repository gitea:3000/admin/chepy (id: 2) after 3 attempts. Error: Error: Failed to clone repository
sourcebot-1 | [backend] | 2025-05-10T05:19:47.285Z error: [RepoManager] Failed to sync repository gitea:3000/admin/foo (id: 1) after 3 attempts. Error: Error: Failed to clone repository
In sourcebot, I do see that it touches the 4 repos (3 marked as private and all are failing). The repos are fine inside gitea itself.
To make sure it is not a network issue, I obtained a shell inside the sourcebot container, and can manually clone any of the repos via specifying the token as the password.
Any suggestions would be great! Maybe a feature request, more verbose error messages would be wonderful.
Thank you for adding the extended logging @msukkari. I think I see the reason why it fails to clone. The following are assumptions of course. I would need to debug it.
TLDR
It seems like the issue is due to a mismatch in clone_url from the api response, and the gitea host that is set in config.json.
So in this case, instead of seeing the repo url as the gitea host (ex. http://gitea:3000/admin/cliam) (although specified in the config (it also gets the repo names correctly because of this - we can validate that in the screenshot above because it shows the valid repo names)), it incorrectly sees the repo url as how gitea sees it and includes in the api response, (ex http://localhost:3000/admin/cliam).
I think your explanation of the the issue makes sense. Your gitea instance isn't aware that it's running in a docker network with Sourcebot so the clone_url it gives back refers to localhost not gitea.
We could support this use case in Sourcebot by adding an clone_url override of some sort in the config. However, I think a quick fix in your case is to spin up your gitea and sourcebot instances seperately and open up the gitea instance port so that sourcebot can hit it using localhost
I believe updating the clone_url is the correct path. The thought is that it would not be an uncommon deployment practice to deploy in compose files, routed via edge routers or k8s clusters where the current implementation of using the gitea supplied clone_url will always break. Specially considering the gitea host url is user configurable, perhaps it would be reasonable to assume that the clone_url will always be hostUrl? Because the current assumption is that hostUrl is the host for clone_url which in the implementation details is not right.
Happy to make a PR if you folks think this fix is the right direction to go. But also agree that if the clone_url base is configurable, that is also an idea path that results in the same outcome.
This fix should probably be fine if we contain it to gitea config compilation. I'd prefer to not change the way we fetch clone_url for other platforms unless we fully understand the side effects. Thanks for looking into this!
Activity
msukkari commentedon Apr 23, 2025
Hey Tim, sorry you're hitting this. Since the specific repos that are failing is changing I suspect this might be a networking issue when cloning the repos (I'm assuming the fail is happening during cloning not indexing from your error log). We've hit this before in certain environments where the networking is limited.
A workaround I would suggest you try is to drop the
maxRepoIndexingJobConcurrencyin the config: https://demo.sourcebot.dev/~/browse/github.com/sourcebot-dev/sourcebot@HEAD/-/blob/schemas/v3/index.json?highlightRange=46%3A1%2C50%3A19Let me know if that helps!
mstimvol commentedon Apr 24, 2025
Hi Michael, changing
maxRepoIndexingJobConcurrencyfrom 8 to 2 finally fixed the error. Thank you very much!securisec commentedon May 10, 2025
@msukkari having the same issue with gitea. Here is my quick test setup. The user
adminhas 4 repos in gitea.docker-compose.yml
config.json
{ "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/refs/heads/main/schemas/v3/index.json", "settings": { "maxConnectionSyncJobConcurrency": 1, "maxRepoIndexingJobConcurrency": 2 }, "connections": { "connection-1": { "type": "gitea", "users": [ "admin" ], "url": "http://gitea:3000", "token": { "env": "GITEA_TOKEN" } } } }The logs show
In sourcebot, I do see that it touches the 4 repos (3 marked as private and all are failing). The repos are fine inside gitea itself.
To make sure it is not a network issue, I obtained a shell inside the sourcebot container, and can manually clone any of the repos via specifying the token as the password.
Any suggestions would be great! Maybe a feature request, more verbose error messages would be wonderful.
msukkari commentedon May 10, 2025
@securisec I added some better logging to git operations in 3.1.4 https://github.com/sourcebot-dev/sourcebot/releases/tag/v3.1.4
Can you try with this new version? It should hopefully help us know whats going on
securisec commentedon May 10, 2025
Thank you for adding the extended logging @msukkari. I think I see the reason why it fails to clone. The following are assumptions of course. I would need to debug it.
TLDR
It seems like the issue is due to a mismatch in clone_url from the api response, and the gitea host that is set in
config.json.In https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/gitea.ts#L26, I can see that it will use the gitea host that i am specifying in the
config.json, but when it uses the gitea api to fetch the repos, https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/gitea.ts#L42-L59, it will will receive back the gitea api response as gitea sees it https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/gitea.ts#L142, but it never updates the git urls https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/repoCompileUtils.ts#L185.So in this case, instead of seeing the repo url as the gitea host (ex.
http://gitea:3000/admin/cliam) (although specified in the config (it also gets the repo names correctly because of this - we can validate that in the screenshot above because it shows the valid repo names)), it incorrectly sees the repo url as how gitea sees it and includes in the api response, (exhttp://localhost:3000/admin/cliam).The raw response from the gitea api is
which means https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/repoCompileUtils.ts#L106 sees the wrong url and fails to clone which is why we see the error
The ideal fix would be in https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/repoCompileUtils.ts#L106 I would imagine. Something like
msukkari commentedon May 10, 2025
I think your explanation of the the issue makes sense. Your gitea instance isn't aware that it's running in a docker network with Sourcebot so the
clone_urlit gives back refers tolocalhostnotgitea.We could support this use case in Sourcebot by adding an
clone_urloverride of some sort in the config. However, I think a quick fix in your case is to spin up your gitea and sourcebot instances seperately and open up the gitea instance port so that sourcebot can hit it usinglocalhostsecurisec commentedon May 10, 2025
I just validated the fix by modifying https://github.com/sourcebot-dev/sourcebot/blob/main/packages/backend/src/repoCompileUtils.ts#L106 with
I believe updating the
clone_urlis the correct path. The thought is that it would not be an uncommon deployment practice to deploy in compose files, routed via edge routers or k8s clusters where the current implementation of using the gitea suppliedclone_urlwill always break. Specially considering the gitea host url is user configurable, perhaps it would be reasonable to assume that theclone_urlwill always behostUrl? Because the current assumption is that hostUrl is the host for clone_url which in the implementation details is not right.Happy to make a PR if you folks think this fix is the right direction to go. But also agree that if the
clone_urlbase is configurable, that is also an idea path that results in the same outcome.msukkari commentedon May 10, 2025
This fix should probably be fine if we contain it to gitea config compilation. I'd prefer to not change the way we fetch
clone_urlfor other platforms unless we fully understand the side effects. Thanks for looking into this!securisec commentedon May 10, 2025
Happy to help. Yes, I believe this impacts gitea only for now (though possible selfhosted gitlab). For now, I will create a PR for gitea only.
Align gitea clone_url with gitea host url. Addresses #270 (#303)