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

[GITLAB] Instructions are wrong for gitlab webhook #358

Closed
Lucas-Froguel opened this issue Oct 6, 2023 · 6 comments
Closed

[GITLAB] Instructions are wrong for gitlab webhook #358

Lucas-Froguel opened this issue Oct 6, 2023 · 6 comments
Labels

Comments

@Lucas-Froguel
Copy link

I followed the tutorial for the gitlab webhook install. I will comment on each step what I think is the issue.

  1. Ok
  2. Ok
  3. Following steps 4-7 of the github install is misleading. In step 5., there is no way to follow:
    - Copy your app's private key to the private_key field.
    - Copy your app's ID to the app_id field.
  4. Supposing in the last step that you should not fill that data, but instead the data from this step, I note that in the [gitlab] section in .secrets.toml only contains:
[gitlab]
# Gitlab personal access token
personal_access_token = ""

Also, the deployment_type variable in configurations.toml is present on the [github] section and is not in the options presented by the comment:

[github]
# The type of deployment to create. Valid values are 'app' or 'user'.
deployment_type = "user"

Also, although not mentioned, I think we need to set git_provider="gitlab" (that is how the container worked for me). As last, the default secret_provider is google_cloud_storage, which gives errors if you have not set up the rest of google. I believe the default should be the local secrets, but I did not find how to do it.
5. Ok
6. Ok

I would love some help from someone, because even identifying some of these errors and trying to set everything right, I was not able to make it work (the container runs, but refuses the connections sent by slee):

Error: connect ECONNREFUSED 0.0.0.0:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '0.0.0.0',
  port: 3000,
  response: undefined
}

with no log message.

@mrT23
Copy link
Collaborator

mrT23 commented Oct 8, 2023

@okotek

@Boyu422
Copy link

Boyu422 commented Nov 1, 2023

I followed the tutorial for the gitlab webhook install. I will comment on each step what I think is the issue.

  1. Ok
  2. Ok
  3. Following steps 4-7 of the github install is misleading. In step 5., there is no way to follow:
    - Copy your app's private key to the private_key field.
    - Copy your app's ID to the app_id field.
  4. Supposing in the last step that you should not fill that data, but instead the data from this step, I note that in the [gitlab] section in .secrets.toml only contains:
[gitlab]
# Gitlab personal access token
personal_access_token = ""

Also, the deployment_type variable in configurations.toml is present on the [github] section and is not in the options presented by the comment:

[github]
# The type of deployment to create. Valid values are 'app' or 'user'.
deployment_type = "user"

Also, although not mentioned, I think we need to set git_provider="gitlab" (that is how the container worked for me). As last, the default secret_provider is google_cloud_storage, which gives errors if you have not set up the rest of google. I believe the default should be the local secrets, but I did not find how to do it.
5. Ok
6. Ok

I would love some help from someone, because even identifying some of these errors and trying to set everything right, I was not able to make it work (the container runs, but refuses the connections sent by slee):

Error: connect ECONNREFUSED 0.0.0.0:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '0.0.0.0',
  port: 3000,
  response: undefined
}

with no log message.

Hello Lucas! I am encountering the same error as yours. Did you fix that error and how you solved the google cloud problem? I would appreciate your response! @Lucas-Froguel

@froque
Copy link

froque commented Nov 10, 2023

What is working for me:

docker-compose.yml

version: '3.2'

services:
  pr-agent:
    image: codiumai/pr-agent:gitlab_webhook
    restart: always
    volumes:
     - ./configuration.toml:/app/pr_agent/settings/configuration.toml
     - ./.secrets.toml:/app/pr_agent/settings/.secrets.toml
    ports:
     - 9101:3000

where configuration.toml has these changes

❯ git diff pr_agent/settings/configuration.toml 
diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml
index dd863eb..2db3875 100644
--- a/pr_agent/settings/configuration.toml
+++ b/pr_agent/settings/configuration.toml
@@ -1,7 +1,7 @@
 [config]
 model="gpt-4" # "gpt-4-1106-preview"
 fallback_models=["gpt-3.5-turbo-16k"]
-git_provider="github"
+git_provider="gitlab"
 publish_output=true
 publish_output_progress=true
 verbosity_level=0 # 0,1,2
@@ -12,7 +12,7 @@ max_description_tokens = 500
 max_commits_tokens = 500
 max_model_tokens = 32000 # Limits the maximum number of tokens that can be used by any model, regardless of the model's default capabilities.
 patch_extra_lines = 3
-secret_provider="google_cloud_storage"
+#secret_provider="google_cloud_storage"
 cli_mode=false
 
 [pr_reviewer] # /review #
@@ -121,7 +121,7 @@ push_commands = [
 
 [gitlab]
 # URL to the gitlab service
-url = "https://gitlab.com"
+url = "https://gitlab.example.com/"
 
 # Polling (either project id or namespace/project_name) syntax can be used
 projects_to_monitor = ['org_name/repo_name']

and .secrets.toml is

[openai]
key = "<some openai key>"

[gitlab]
# Gitlab personal access token
personal_access_token = "<some personal access token>"
shared_secret = "<some shared secret>"

[github]
deployment_type = "gitlab"

@mrT23 mrT23 added the solved label Dec 17, 2023
@mrT23
Copy link
Collaborator

mrT23 commented Dec 17, 2023

thanks @froque

@mrT23 mrT23 closed this as completed Dec 17, 2023
@dima-hx
Copy link

dima-hx commented Dec 26, 2023

Thanks @froque .

By the way, in GitLab you should specify a webhook URL with a specific path! (/webhook)

For @froque example it would be http://youcontainer.com:9101/webhook

@prasadnaikg-ldp
Copy link

prasadnaikg-ldp commented Aug 5, 2024

I'm trying to similar approach as mentioned above

in ec2 , I have created instance and using webhook image ,
but getting following issue
ubuntu@ip-172-31-9-150:$ sudo docker-compose up
[+] Running 2/2
✔ Network ubuntu_default Created 0.1s
✔ Container ubuntu-pr-agent-1 Created 0.1s
Attaching to ubuntu-pr-agent-1
ubuntu-pr-agent-1 | Traceback (most recent call last):
ubuntu-pr-agent-1 | File "/app/pr_agent/servers/gitlab_webhook.py", line 14, in
ubuntu-pr-agent-1 | from pr_agent.agent.pr_agent import PRAgent
ubuntu-pr-agent-1 | File "/app/pr_agent/agent/pr_agent.py", line 9, in
ubuntu-pr-agent-1 | from pr_agent.git_providers.utils import apply_repo_settings
ubuntu-pr-agent-1 | File "/app/pr_agent/git_providers/init.py", line 6, in
ubuntu-pr-agent-1 | from pr_agent.git_providers.github_provider import GithubProvider
ubuntu-pr-agent-1 | File "/app/pr_agent/git_providers/github_provider.py", line 22, in
ubuntu-pr-agent-1 | class GithubProvider(GitProvider):
ubuntu-pr-agent-1 | File "/app/pr_agent/git_providers/github_provider.py", line 132, in GithubProvider
ubuntu-pr-agent-1 | tries=get_settings().github.ratelimit_retries, delay=2, backoff=2, jitter=(1, 3))
ubuntu-pr-agent-1 | File "/usr/local/lib/python3.10/site-packages/dynaconf/utils/boxing.py", line 21, in evaluate
ubuntu-pr-agent-1 | value = f(dynabox, item, *args, **kwargs)
ubuntu-pr-agent-1 | File "/usr/local/lib/python3.10/site-packages/dynaconf/utils/boxing.py", line 44, in getattr
ubuntu-pr-agent-1 | return super().getattr(n_item, *args, **kwargs)
ubuntu-pr-agent-1 | File "/usr/local/lib/python3.10/site-packages/dynaconf/vendor/box/box.py", line 176, in getattr
ubuntu-pr-agent-1 | raise BoxKeyError(str(E))from _A
ubuntu-pr-agent-1 | dynaconf.vendor.box.exceptions.BoxKeyError: "'DynaBox' object has no attribute 'ratelimit_retries'"
ubuntu-pr-agent-1 exited with code 0
ubuntu@ip-172-31-9-150:
$

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

No branches or pull requests

6 participants