Open rawbin- opened 1 month ago
Starting the CRA...
Bito Code Review Agent is running as: server
hex string is too long invalid hex key value Use below as Gitlab and Github Webhook secret: 88da24e896aec8dd9519ae31f014128c
Running command: docker pull bitoai/cra:latest latest: Pulling from bitoai/cra Digest: sha256:f41b7bc805c250c1ed8777ff4fa6873e2e44886033ae575711adb28d12d52e02 Status: Image is up to date for bitoai/cra:latest docker.io/bitoai/cra:latest Docker image pulled successfully. Running command: eval docker run --rm -it -p ${server_port}:${server_port} -d ${docker_repo}:${cra_version} --mode=server --code_feedback=True --bee.path=/automation-platform --bee.actn_dir=/automation-platform/default_bito_ad/bito_modules --git.provider=GITLAB --git.access_token=code-git--zSnHYKfu2hFj7ZHsu_b --bito_cli.bito.access_key=1monthFREE24H4 --review_comments=INLINE --static_analysis.fb_infer.enabled=True --static_analysis_tool=fb_infer,astral_ruff,mypy --exclude_branches='main,master' --exclude_files='.xml,.json,.properties,.gitignore,.yml,*.md' --exclude_draft_pr=True --dependency_check.enabled=False --server_port=10051 --code_context=True --cr_event_type=automated --posting_to_pr=True ${docker_enc_params} > "/root/.bitoai/bitocra.cid"
Hi,
Please refer to the self-hosted details at: https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-as-a-self-hosted-service/install-run-via-webhooks-service Reference: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#configure-a-webhook-in-gitlab
Once the "./bito-cra.sh service start bito-cra.properties" is executed, you would need to configure GitLab Webhook instead of making curl calls.
Are all the steps mentioned in above document are followed to configure GitLab webhook? Please let us know.
Thanks.
Hi,
Please refer to the self-hosted details at: https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-as-a-self-hosted-service/install-run-via-webhooks-service Reference: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#configure-a-webhook-in-gitlab
Once the "./bito-cra.sh service start bito-cra.properties" is executed, you would need to configure GitLab Webhook instead of making curl calls.
Are all the steps mentioned in above document are followed to configure GitLab webhook? Please let us know.
Thanks.
I got the curl calls info from gitlab webhook request logs, I wonder if there is some problem other than the webhook request itself.
Is there some way for us to check if the self-hosted service is working well ? or some way for further infomation for the error?
HI,
Please note below points:
We realized that the Bito workspace associated with email fcrshjx44@gmail.com is on free plan and to use code review agent, please upgrade to paid plan. We are happy to give you a free 1 month trial of the 10x Developer Plan (paid plan), which includes our AI Code Review Agent. Please use this code during the checkout process: 1monthFREE24H4 . You will need to enter your payment info, but this will give you a full 1 month free of the $15 base charge. You can upgrade by clicking Upgrade by going to https://bito.ai/ & clicking Sign In in the top navbar, go to Billing and Plans in the left navbar, and then upgrading your workspace there. You can cancel at any time.
Once the the workspace is on paid plan, please make sure that these 3 parameters are configured correctly in file bito-cra.properties i> git.provider=GITLAB ii> git.access_token iii> bito_cli.bito.access_key. Please refer to https://docs.bito.ai/account-and-settings/access-key for how to create Bito Access Key. If these parameters are not configured correctly then WebHook won't get expected response.
After configuration all the required parameters in bito-cra.properties as mentioned in point no.2 , execute "./bito-cra.sh service restart bito-cra.properties". It will give you the web-secret in encrypted format under the tag "Use below as Gitlab and Github Webhook secret:".
Further it will give Code Review Agent URL: http://127.0.0.1:10051/ Note: Use above URL to configure GITLAB/GITHUB web-hook by replacing IP adderss with the IP address or Domain Name of your server. The final URL to be used for GITLAB web-hook https://<domain name/ip-address>/api/v1/gitlab_webhhooks (We are assuming that http://mytest.example.com/api/v1/gitlab_webhooks is a valid URL.)
Configure the GITLAB webhook as stated in the document link shared earlier using secret and URL as mentioned above.
Other commands to check/stop/start/restart self-hosted Code Review Agent:
Please let me know if you face any issues and I will be happy to get on the call. Thanks.
I am using the code 1monthFREE24H4
from the page https://alpha.bito.ai/home/welcome. Because I have tried to get code from this from https://share.hsforms.com/15v5GKpm5QNmC7mjC3hfSVwnibfq from page https://docs.bito.ai/bito-dev-agents/ai-code-review-agent, but I get nothing, it never send me anything.
So the main problem at present is that the code is not on paid plan? But it seems like a general code and there is no information to combine the code in bito-cra.properties with my email account. And I can see that it is available on free plan. https://alpha.bito.ai/home/bito-premium/change-plan
HI,
Please note below points:
- We realized that the Bito workspace associated with email fcrshjx44@gmail.com is on free plan and to use code review agent, please upgrade to paid plan. We are happy to give you a free 1 month trial of the 10x Developer Plan (paid plan), which includes our AI Code Review Agent. Please use this code during the checkout process: 1monthFREE24H4 . You will need to enter your payment info, but this will give you a full 1 month free of the $15 base charge. You can upgrade by clicking Upgrade by going to https://bito.ai/ & clicking Sign In in the top navbar, go to Billing and Plans in the left navbar, and then upgrading your workspace there. You can cancel at any time.
- Once the the workspace is on paid plan, please make sure that these 3 parameters are configured correctly in file bito-cra.properties i> git.provider=GITLAB ii> git.access_token iii> bito_cli.bito.access_key. Please refer to https://docs.bito.ai/account-and-settings/access-key for how to create Bito Access Key. If these parameters are not configured correctly then WebHook won't get expected response.
- After configuration all the required parameters in bito-cra.properties as mentioned in point no.2 , execute "./bito-cra.sh service restart bito-cra.properties". It will give you the web-secret in encrypted format under the tag "Use below as Gitlab and Github Webhook secret:".
- Further it will give Code Review Agent URL: http://127.0.0.1:10051/ Note: Use above URL to configure GITLAB/GITHUB web-hook by replacing IP adderss with the IP address or Domain Name of your server. The final URL to be used for GITLAB web-hook https://<domain name/ip-address>/api/v1/gitlab_webhhooks (We are assuming that http://mytest.example.com/api/v1/gitlab_webhooks is a valid URL.)
- Configure the GITLAB webhook as stated in the document link shared earlier using secret and URL as mentioned above.
- Other commands to check/stop/start/restart self-hosted Code Review Agent:
- ./bito-cra.sh service restart bito-cra.properties. ==> To restart the self-hosted Code Review Agent
- ./bito-cra.sh service stop bito-cra.properties ==> To stop the self-hosted Code Review Agent
- ./bito-cra.sh service stop bito-cra.properties ==> To start the self-hosted Code Review Agent
- /bito-cra.sh service status bito-cra.properties ==> To check status of the self-hosted Code Review Agent
Please let me know if you face any issues and I will be happy to get on the call. Thanks.
mode=server
pr_url=
code_feedback=True
bito_cli.bito.access_key=1monthFREE24H4
git.provider=GITLAB
git.access_token=code-git--xxx[replaced by real code]
git.domain=
static_analysis=True
static_analysis_tool=fb_infer,astral_ruff,mypy
review_scope=
dependency_check=False
code_context=True
dependency_check.snyk_auth_token=
review_comments=2
server_port=10051
cra_version=latest
exclude_branches=main,master
exclude_files=*.xml,*.json,*.properties,.gitignore,*.yml,*.md
exclude_draft_pr=True
# ./bito-cra.sh service start bito-cra.properties
Starting the CRA...
Bito Code Review Agent is running as: server
hex string is too long invalid hex key value Use below as Gitlab and Github Webhook secret: 88da24e896aec8dd9519ae31f014128c
Running command: docker pull bitoai/cra:latest latest: Pulling from bitoai/cra Digest: sha256:f41b7bc805c250c1ed8777ff4fa6873e2e44886033ae575711adb28d12d52e02 Status: Image is up to date for bitoai/cra:latest docker.io/bitoai/cra:latest Docker image pulled successfully. Running command: eval docker run --rm -it -p ${server_port}:${server_port} -d ${docker_repo}:${cra_version} --mode=server --code_feedback=True --bee.path=/automation-platform --bee.actn_dir=/automation-platform/default_bito_ad/bito_modules --git.provider=GITLAB --git.access_token=code-git--zSnHYKfu2hFj7ZHsu_b --bito_cli.bito.access_key=1monthFREE24H4 --review_comments=INLINE --static_analysis.fb_infer.enabled=True --static_analysis_tool=fb_infer,astral_ruff,mypy --exclude_branches='main,master' --exclude_files='.xml,.json,.properties,.gitignore,.yml,*.md' --exclude_draft_pr=True --dependency_check.enabled=False --server_port=10051 --code_context=True --cr_event_type=automated --posting_to_pr=True ${docker_enc_params} > "/root/.bitoai/bitocra.cid"
4. Check the service
Checking the CRA... CRA is running.
5. Run the service with local hosts. But failed even with full gitlab merge request webhook request got from gitlab webhook recent events detail page. And it works on other webhook api.
❯ curl -X POST http://mytest.example.com/api/v1/gitlab_webhooks
"Unauthorized: Secret is not valid"%
❯ curl -X POST -H 'Content-Type: application/json' -H "X-Gitlab-Token: 88da24e896aec8dd9519ae31f014128c" http://mytest.example.com/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"%
❯ curl -X POST -H 'Content-Type: application/json' -H "X-Gitlab-Token: 88da24e896aec8dd9519ae31f014128c" http://mytest.example.com/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"%
❯ curl -X POST -H 'Content-Type: application/json' -H "User-Agent: GitLab/17.2.1-ee" -H "X-Gitlab-Event: Merge Request Hook" -H "X-Gitlab-Webhook-UUID: d9c303c5-9ddd-4d7c-8355-0f2f63c4fd99" -H "X-Gitlab-Token: 88da24e896aec8dd9519ae31f014128c" -H "X-Gitlab-Event-UUID: 63ab84ed-f9a7-419a-a8d5-7eb2dd4e5e06" --json @gitlab-mr-body.json http://mytest.example.com/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"%
hi @rawbin-
Sorry for the confusion.
Please follow below steps to get a Trial -
Thanks, Nisha
Also setting the "bito_cli.bito.access_key=1monthFREE24H4" in bito-cra.properties is not correct. Please refer to the below instructions in my previous reply.
Once the the workspace is on paid plan, please make sure that these 3 parameters are configured correctly in file bito-cra.properties i> git.provider=GITLAB ii> git.access_token iii> bito_cli.bito.access_key. Please refer to https://docs.bito.ai/account-and-settings/access-key for how to create Bito Access Key. If these parameters are not configured correctly then WebHook won't get expected response.
@adhirpotdarbito @nisha-bito thank you very much for you kindness. I did the following steps:
# curl -X POST -H 'Content-Type: application/json' -H "User-Agent: GitLab/17.2.1-ee" -H "X-Gitlab-Event: Merge Request Hook" -H "X-Gitlab-Webhook-UUID: d9c303c5-9ddd-4d7c-8355-0f2f63c4fd99" -H "X-Gitlab-Token: b76c3b67ae97a3c54b35985e2c155818" -H "X-Gitlab-Event-UUID: 63ab84ed-f9a7-419a-a8d5-7eb2dd4e5e06" -d @gitlab-webhook-mr-body.json http://127.0.0.1:10051/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"
Hi @rawbin-
This error comes when GITLAB webhook body JSON is not having all required parameters, i.e. in your case it is file "gitlab-webhook-mr-body.json" used in curl call with -d option. Can you please share this JSON file?
Alternatively, instead of curl call, I would suggest to configure the webhook, create a new PR to trigger the code review session.
Thanks.
Hi @rawbin-
This error comes when GITLAB webhook body JSON is not having all required parameters, i.e. in your case it is file "gitlab-webhook-mr-body.json" used in curl call with -d option. Can you please share this JSON file?
Alternatively, instead of curl call, I would suggest to configure the webhook, create a new PR to trigger the code review session.
Thanks.
The request body is copied from gitlab webhook log page, It's params for gitlab webhook tests. I replace some info for sensibility reason but with full structure.
{
"object_kind": "merge_request",
"event_type": "merge_request",
"user": {
"id": 348,
"name": "userA",
"username": "userA",
"avatar_url": "https://domainA.com/avatar/aaaa?s=80&d=identicon",
"email": "userA@gmail.com"
},
"project": {
"id": 114,
"name": "projectA",
"description": "项目A",
"web_url": "https://gitlab.example.com/arch/path/projectA",
"avatar_url": null,
"git_ssh_url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"git_http_url": "https://gitlab.example.com/arch/path/to/project/projectA.git",
"namespace": "projectNamespace",
"visibility_level": 0,
"path_with_namespace": "arch/path/to/project/projectA",
"default_branch": "master",
"ci_config_path": "",
"homepage": "https://gitlab.example.com/arch/path/to/project/projectA",
"url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"ssh_url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"http_url": "https://gitlab.example.com/arch/path/to/project/projectA.git"
},
"object_attributes": {
"assignee_id": 63,
"author_id": 126,
"created_at": "2024-09-24 20:35:53 +0800",
"description": "提交信息描述",
"draft": false,
"head_pipeline_id": null,
"id": 139339,
"iid": 11288,
"last_edited_at": null,
"last_edited_by_id": null,
"merge_commit_sha": "4a1bd95af2f081d843f9b97fd6aa457c0f94d96c",
"merge_error": null,
"merge_params": {
"force_remove_source_branch": null
},
"merge_status": "can_be_merged",
"merge_user_id": null,
"merge_when_pipeline_succeeds": false,
"milestone_id": null,
"source_branch": "feature_activity_dashboard_923",
"source_project_id": 114,
"state_id": 3,
"target_branch": "release_testnet",
"target_project_id": 114,
"time_estimate": 0,
"title": "提交信息",
"updated_at": "2024-09-24 20:36:05 +0800",
"updated_by_id": null,
"prepared_at": "2024-09-24 20:35:54 +0800",
"assignee_ids": [63],
"blocking_discussions_resolved": true,
"detailed_merge_status": "not_open",
"first_contribution": false,
"human_time_change": null,
"human_time_estimate": null,
"human_total_time_spent": null,
"labels": [],
"last_commit": {
"id": "8837fb22fe8ac4655cbd3bc090a25b5f794330c4",
"message": "feat: 提交信息\n",
"title": "feat: 提交信息",
"timestamp": "2024-09-24T20:35:17+08:00",
"url": "https://gitlab.example.com/arch/path/to/project/projectA/-/commit/8837fb22fe8ac4655cbd3bc090a25b5f794330c4",
"author": {
"name": "userB",
"email": "userB@gmail.com"
}
},
"reviewer_ids": [],
"source": {
"id": 114,
"name": "projectA",
"description": "项目A",
"web_url": "https://gitlab.example.com/arch/path/to/project/projectA",
"avatar_url": null,
"git_ssh_url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"git_http_url": "https://gitlab.example.com/arch/path/to/project/projectA.git",
"namespace": "projectNamespace",
"visibility_level": 0,
"path_with_namespace": "arch/path/to/project/projectA",
"default_branch": "master",
"ci_config_path": "",
"homepage": "https://gitlab.example.com/arch/path/to/project/projectA",
"url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"ssh_url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"http_url": "https://gitlab.example.com/arch/path/to/project/projectA.git"
},
"state": "merged",
"target": {
"id": 114,
"name": "projectA ",
"description": "项目A",
"web_url": "https://gitlab.example.com/arch/path/to/project/projectA",
"avatar_url": null,
"git_ssh_url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"git_http_url": "https://gitlab.example.com/arch/path/to/project/projectA.git",
"namespace": "projectNamespace",
"visibility_level": 0,
"path_with_namespace": "arch/path/to/project/projectA",
"default_branch": "master",
"ci_config_path": "",
"homepage": "https://gitlab.example.com/arch/path/to/project/projectA",
"url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"ssh_url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"http_url": "https://gitlab.example.com/arch/path/to/project/projectA.git"
},
"time_change": 0,
"total_time_spent": 0,
"url": "https://gitlab.example.com/arch/path/to/project/projectA/-/merge_requests/11288",
"work_in_progress": false,
"approval_rules": [
{
"id": 46157,
"created_at": "2024-09-24 20:35:53 +0800",
"updated_at": "2024-09-24 20:36:05 +0800",
"merge_request_id": 139339,
"approvals_required": 0,
"name": "All Members",
"rule_type": "any_approver",
"report_type": null,
"section": null,
"modified_from_project_rule": false,
"orchestration_policy_idx": null,
"vulnerabilities_allowed": 0,
"scanners": [],
"severity_levels": [],
"vulnerability_states": ["new_needs_triage", "new_dismissed"],
"security_orchestration_policy_configuration_id": null,
"scan_result_policy_id": null,
"applicable_post_merge": true,
"project_id": 114,
"approval_policy_rule_id": null
}
],
"action": "open"
},
"labels": [],
"changes": {},
"repository": {
"name": "projectA ",
"url": "git@gitlab.example.com:arch/path/to/project/projectA.git",
"description": "项目A",
"homepage": "https://gitlab.example.com/arch/path/to/project/projectA"
},
"assignees": [
{
"id": 63,
"name": "userB",
"username": "userB",
"avatar_url": "https://domainA.com/avatar/bbbb?s=80&d=identicon",
"email": "userB@gmail.com"
}
]
}
Thanks and we will check & get back to you.
Hi @rawbin-
We see below issue in a curl call:
curl -X POST -H 'Content-Type: application/json' -H "User-Agent: GitLab/17.2.1-ee" -H "X-Gitlab-Event: Merge Request Hook" -H "X-Gitlab-Webhook-UUID: d9c303c5-9ddd-4d7c-8355-0f2f63c4fd99" -H "X-Gitlab-Token: b76c3b67ae97a3c54b35985e2c155818" -H "X-Gitlab-Event-UUID: 63ab84ed-f9a7-419a-a8d5-7eb2dd4e5e06" -d @gitlab-webhook-mr-body.json http://127.0.0.1:10051/api/v1/gitlab_webhooks "Oops!! Something Went Wrong. Please try again after some time"
X-Gitlab-Token: b76c3b67ae97a3c54b35985e2c155818 is not valid token, please use the secret provided by the bash script under the tag "Use below as Gitlab and Github Webhook secret:".
Please repair and try out the curl call again.
Note: We will put fix in future release such that instead of "Oops!! Something Went Wrong", we will give proper error.
Thanks
Hi @rawbin-
Just following up on the previous message. Were you able to update the curl call with the correct X-Gitlab-Token
?
Please make sure to use the secret provided by the bash script under the tag "Use below as Gitlab and Github Webhook secret:".
Let us know if you need any further assistance.
Thanks!
Hi @rawbin-
We see below issue in a curl call:
curl -X POST -H 'Content-Type: application/json' -H "User-Agent: GitLab/17.2.1-ee" -H "X-Gitlab-Event: Merge Request Hook" -H "X-Gitlab-Webhook-UUID: d9c303c5-9ddd-4d7c-8355-0f2f63c4fd99" -H "X-Gitlab-Token: b76c3b67ae97a3c54b35985e2c155818" -H "X-Gitlab-Event-UUID: 63ab84ed-f9a7-419a-a8d5-7eb2dd4e5e06" -d @gitlab-webhook-mr-body.json http://127.0.0.1:10051/api/v1/gitlab_webhooks "Oops!! Something Went Wrong. Please try again after some time"
X-Gitlab-Token: b76c3b67ae97a3c54b35985e2c155818 is not valid token, please use the secret provided by the bash script under the tag "Use below as Gitlab and Github Webhook secret:".
Please repair and try out the curl call again.
Note: We will put fix in future release such that instead of "Oops!! Something Went Wrong", we will give proper error.
Thanks
I am exactly using the token from the staring up output。
It changes when starting up ,so it is not all the same, and I updated it each time when restart.
Hi @rawbin-
Thank you for getting back to us. Could you please check the value set in bito_cli.bito.access_key and let us know whether your Git access token is classic or fine-grained? This will help us verify if the Git access token and Bito access key have been provided correctly.
❯ curl -X POST http://mytest.example.com/api/v1/gitlab_webhooks
"Unauthorized: Secret is not valid"%
❯ curl -X POST -H 'Content-Type: application/json' -H "X-Gitlab-Token: 88da24e896aec8dd9519ae31f014128c" http://mytest.example.com/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"%
❯ curl -X POST -H 'Content-Type: application/json' -H "X-Gitlab-Token: 88da24e896aec8dd9519ae31f014128c" http://mytest.example.com/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"%
❯ curl -X POST -H 'Content-Type: application/json' -H "User-Agent: GitLab/17.2.1-ee" -H "X-Gitlab-Event: Merge Request Hook" -H "X-Gitlab-Webhook-UUID: d9c303c5-9ddd-4d7c-8355-0f2f63c4fd99" -H "X-Gitlab-Token: 88da24e896aec8dd9519ae31f014128c" -H "X-Gitlab-Event-UUID: 63ab84ed-f9a7-419a-a8d5-7eb2dd4e5e06" --json @gitlab-mr-body.json http://mytest.example.com/api/v1/gitlab_webhooks
"Oops!! Something Went Wrong. Please try again after some time"%