dosubot[bot] commented on issue #7893: URL: https://github.com/apache/incubator-devlake/issues/7893#issuecomment-2287256093
<!-- Answer --> To resolve the error "subtask Clone Git Repo ended unexpectedly Wraps: (2) git exit error Error types: (1) *hintdetail.withDetail (2) *errors.errorString" and successfully add your repository, follow these steps: 1. **Check Proxy Settings**: Ensure that the proxy settings are correctly configured if you are using a proxy. Verify that the `taskData.Options.Proxy` is set correctly. 2. **Verify Private Key Handling**: If you are using SSH with a private key, ensure that the private key and passphrase are correctly handled. The code creates a temporary file for the private key and sets the appropriate permissions. Ensure that this process is not failing. 3. **Check Git Command Execution**: Ensure that the `execGitCommand` and `execGitCommandIn` functions are correctly handling the git commands and their environment. Verify that the commands are correctly formed and that the environment variables are set properly. 4. **Handle Shallow Clone Issues**: Ensure that the `--depth=1` and `--shallow-since` options are used correctly if you are performing a shallow clone. Additionally, ensure that the `CloneGitRepo` function in the `CloneGitRepoMeta` subtask is correctly implemented. Here is the relevant part of the code: ```go func CloneGitRepo(subTaskCtx plugin.SubTaskContext) errors.Error { taskData, ok := subTaskCtx.GetData().(*parser.GitExtractorTaskData) if (!ok) { panic("git repo reference not found on context") } op := taskData.Options storage := store.NewDatabase(subTaskCtx, op.RepoId) var err errors.Error logger := subTaskCtx.GetLogger() // temporary dir for cloning localDir, e := os.MkdirTemp("", "gitextractor") if e != nil { return errors.Convert(e) } // clone repo repoCloner := parser.NewGitcliCloner(subTaskCtx) err = repoCloner.CloneRepo(subTaskCtx, localDir) if err != nil { if errors.Is(err, parser.ErrNoData) { taskData.SkipAllSubtasks = true return nil } return err } if repoCloner.IsIncremental() { storage.SetIncrementalMode(repoCloner.IsIncremental()) } // We have done comparison experiments for git2go and go-git, and the results show that git2go has better performance. var repoCollector parser.RepoCollector if *taskData.Options.UseGoGit { repoCollector, err = parser.NewGogitRepoCollector(localDir, op.RepoId, storage, logger) } else { repoCollector, err = parser.NewLibgit2RepoCollector(localDir, op.RepoId, storage, logger) } if err != nil { return err } // inject clean up callback to remove the cloned dir cleanup := func() { _ = os.RemoveAll(localDir) } if e := repoCollector.SetCleanUp(cleanup); e != nil { return errors.Convert(e) } // pass the collector down to next subtask taskData.GitRepo = repoCollector subTaskCtx.TaskContext().SetData(taskData) return nil } ``` ### Additional Troubleshooting Steps 1. **Self-Signed Certificates**: If you are using a private GitLab server with a self-signed certificate, add your root CA to the `devlake` container. Mount your `rootCA.crt` into the container and update the CA certificates. Example for `docker-compose`: ```yaml devlake: image: apache/devlake:v... ... volumes: ... - /path/to/your/rootCA.crt:/usr/local/share/ca-certificates/rootCA.crt command: [ "sh", "-c", "update-ca-certificates; lake" ] ... ``` 2. **Upgrade to Latest Version**: Consider upgrading to the latest version of DevLake (v0.15.x or later) as some bugs have been fixed in newer versions. 3. **Check Token Permissions**: Ensure that your access token has the necessary permissions. If your account is protected by organization SAML enforcement, make sure you've authorized the token using SSO. 4. **Error Code 403**: If you encounter an error with the status code 403, it is usually caused by the permission of your tokens. Ensure you are using a supported authentication method and that your token has the necessary permissions. 5. **Error Code 429**: If you encounter an error with the status code 429, it is usually caused by rate limiting. Enable `fixed rate limit` in the GitLab connection and lower the API rates to 2,000. If it works, you can try increasing the rates to accelerate <sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitextractor/parser/clone_gitcli.go)</sup><sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitextractor/tasks/repo_cloner.go)</sup><sup>[[3]](https://github.com/apache/incubator-devlake-website/blob/main/docs/Troubleshooting/Configuration.md)</sup><sup>[[4]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v0.21/Troubleshooting/Configuration.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org