-
Notifications
You must be signed in to change notification settings - Fork 596
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
Running on Azure DevOps Pipeline error #1200
Comments
work from CLI, and debug. |
Thank you. We will try that when we get into the office on Monday.
From: Tal ***@***.***>
Sent: Saturday, September 7, 2024 12:44 AM
To: Codium-ai/pr-agent ***@***.***>
Cc: Daniel Mohr ***@***.***>; Author ***@***.***>
Subject: Re: [Codium-ai/pr-agent] Running on Azure DevOps Pipeline error (Issue #1200)
[CAUTION]: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
work from CLI, and debug.
make sure the result of
self.workspace_slug, self.repo_slug, self.pr_num = self._parse_pr_url(pr_url)
makes sense
-
Reply to this email directly, view it on GitHub<#1200 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A2LAPAH62ZW2LB4VQVV6O7DZVKAAVAVCNFSM6AAAAABNZMFQHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZVGAZTSOBXGQ>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
I am still having this issue and have tried a few things. Here is where I think the issue is.... Description:The PR Agent fails to recognize valid Azure DevOps PR URLs in the Error Message:
Steps to Reproduce:
Expected Behavior:The PR Agent should be able to handle both Azure DevOps URL formats:
Actual Behavior:The PR Agent raises a Potential Cause:The issue appears to be in the Possible Fix:Im not totaly sure but... Modify the import re
def _parse_pr_url(self, pr_url):
# Support both dev.azure.com and visualstudio.com formats
match = re.match(r'https://(?:[^.]+\.visualstudio\.com|dev\.azure\.com)/([^/]+)/_git/([^/]+)/pullrequest/(\d+)', pr_url)
if not match:
raise ValueError("The provided URL does not appear to be a valid Azure DevOps PR URL")
return match.groups() # Organization, Project, Repo, PR ID This will allow the PR Agent to parse both URL formats correctly. Workaround (If Applicable):One potential workaround is to manually rewrite the Environment:
All in all I really want to implement this tool so would love some help. |
@MikesHorcrux make sure to properly change your organization:
to
if it works, it can be merged to production |
@mrT23 Ill test this after its merged in when do you think this will be approved |
@MikesHorcrux checkout the branch, run it via CLI, and give feedback if it works, or not. that is the path for merging |
@mrT23 and @MikesHorcrux, your fix seems to work, in the sense that it gets past that first error. Thank you. It seems to parse the visualstudio.com format. I also found that based on your guy's conversation changing the URL in you azure pipeline example seem to have a similar effect: # Construct PR_URL It could be unique to my company but we needed the extra ${SYSTEM_TEAMPROJECT} for the link to work in the dev.azure.com format. I do not know if that applies to all DevOps, though. We can try the other format on the pipeline once you push the PR. But it seems that in either case we run into a similar error: For the PR that you asked Mike to try, we got this: 2024-09-11 12:54:50.562 | ERROR | pr_agent.git_providers.azuredevops_provider:get_diff_files:353 - Failed to retrieve original file content of /TestRepo/TestRepo/badcode.swift at version {'additional_properties': {}, 'version': '0b487f9de5cc6cf2bc79654fb8b418db03f56ca4', 'version_options': None, 'version_type': 'commit'}. Error: TF401174: The item 'TestRepo/TestRepo/badcode.swift' could not be found in the repository 'PRAGENTTEST' at the version specified by '<Commit: 0b487f9de5cc6cf2bc79654fb8b418db03f56ca4 >' (resolved to commit '0b487f9de5cc6cf2bc79654fb8b418db03f56ca4') And for the pipeline we got this error: Both are about round the additional_properties which is only in one part of the code. The only debugging we did so far was for these values right before the error, and they looked correct. This was also only on the local cli build and not the azure pipeline, just to be clear.
I will try to look at this a bit later to see if I can find a smoking gun, but I am really not a Python dev (it does not come up for me as much as I would like), so I am learning on the fly. Any ideas what causes the additional_properties errors? |
As the API result seem different for this kind of repo, in order to fully solve the issue, you will need to edit the PR (or start a new one). |
Not sure if my comment will be helpful here or not, but I see a similar error for Azure DevOps PRs when the file that the PR-Agent is attempting to download were new in this PR. For example I raise a PR that is adding new file call
as it gets a 404 when it tries to lookup the previous version of this file from Azure DevOps. If I create a PR with only file modifications on existing files, the PR-Agent operations work as expected. I think this may be at least part of the error that is being discussed here. |
I have created a separate issue for this as well as a PR to fix the issue |
This seems to work with the latest pushes. Thanks. You guys can close this one. |
I was following the directions to run from an azure pipeline in devops. https://pr-agent-docs.codium.ai/installation/azure/
It took me a bit to get the pr trigger to work but I think that I got it in the end. My issue is that does not seem to like the url to my PR. I pasted the generated url into the browser and it goes to the PR page in devops so i am not sure what the issue is. Do you have any suggestions?
The yaml is the exact same as the example, no changes. The logs below are the same except for my company name being replaced with xxxxxx.
Thanks,
2024-09-06T21:30:30.1632154Z ##[section]Starting: Run PR Agent
2024-09-06T21:30:30.1636570Z ==============================================================================
2024-09-06T21:30:30.1636688Z Task : Command line
2024-09-06T21:30:30.1636749Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2024-09-06T21:30:30.1636855Z Version : 2.244.3
2024-09-06T21:30:30.1636911Z Author : Microsoft Corporation
2024-09-06T21:30:30.1636994Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2024-09-06T21:30:30.1637109Z ==============================================================================
2024-09-06T21:30:30.5754461Z Generating script.
2024-09-06T21:30:30.5762937Z ========================== Starting Command Output ===========================
2024-09-06T21:30:30.5776340Z [command]/usr/bin/bash --noprofile --norc /__w/_temp/45bab00e-475c-430b-bdd9-a346011f724f.sh
2024-09-06T21:30:30.5832333Z Running PR Agent action step
2024-09-06T21:30:30.5832617Z PR_URL=https://xxxxxxx.visualstudio.com/xxxxxxxxx/_git/XXXXXMobile/pullrequest/23232
2024-09-06T21:30:30.5848390Z Organization URL: https://xxxxxxx.visualstudio.com
2024-09-06T21:30:35.1532178Z Traceback (most recent call last):
2024-09-06T21:30:35.1532432Z File "/app/pr_agent/git_providers/init.py", line 57, in get_git_provider_with_context
2024-09-06T21:30:35.1532676Z git_provider = _GIT_PROVIDERSprovider_id
2024-09-06T21:30:35.1532819Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1532991Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 56, in init
2024-09-06T21:30:35.1533155Z self.set_pr(pr_url)
2024-09-06T21:30:35.1533334Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 190, in set_pr
2024-09-06T21:30:35.1533545Z self.workspace_slug, self.repo_slug, self.pr_num = self._parse_pr_url(pr_url)
2024-09-06T21:30:35.1533704Z ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1533904Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 554, in _parse_pr_url
2024-09-06T21:30:35.1534070Z raise ValueError(
2024-09-06T21:30:35.1534239Z ValueError: The provided URL does not appear to be a Azure DevOps PR URL
2024-09-06T21:30:35.1534331Z
2024-09-06T21:30:35.1534473Z The above exception was the direct cause of the following exception:
2024-09-06T21:30:35.1534575Z
2024-09-06T21:30:35.1534691Z Traceback (most recent call last):
2024-09-06T21:30:35.1535105Z File "/usr/local/bin/pr-agent", line 8, in
2024-09-06T21:30:35.1535258Z sys.exit(run())
2024-09-06T21:30:35.1535361Z ^^^^^
2024-09-06T21:30:35.1535482Z File "/app/pr_agent/cli.py", line 88, in run
2024-09-06T21:30:35.1535640Z result = asyncio.run(inner())
2024-09-06T21:30:35.1535755Z ^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1535910Z File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
2024-09-06T21:30:35.1536070Z return runner.run(main)
2024-09-06T21:30:35.1536196Z ^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1536340Z File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
2024-09-06T21:30:35.1536512Z return self._loop.run_until_complete(task)
2024-09-06T21:30:35.1536655Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1536924Z File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
2024-09-06T21:30:35.1537111Z return future.result()
2024-09-06T21:30:35.1537220Z ^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1537343Z File "/app/pr_agent/cli.py", line 79, in inner
2024-09-06T21:30:35.1537557Z result = await asyncio.create_task(PRAgent().handle_request(args.pr_url, [command] + args.rest))
2024-09-06T21:30:35.1537733Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1537893Z File "/app/pr_agent/agent/pr_agent.py", line 57, in handle_request
2024-09-06T21:30:35.1538401Z apply_repo_settings(pr_url)
2024-09-06T21:30:35.1538690Z File "/app/pr_agent/git_providers/utils.py", line 14, in apply_repo_settings
2024-09-06T21:30:35.1538877Z git_provider = get_git_provider_with_context(pr_url)
2024-09-06T21:30:35.1539013Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:35.1539188Z File "/app/pr_agent/git_providers/init.py", line 62, in get_git_provider_with_context
2024-09-06T21:30:35.1539391Z raise ValueError(f"Failed to get git provider for {pr_url}") from e
2024-09-06T21:30:35.1539647Z ValueError: Failed to get git provider for https://xxxxxx.visualstudio.com/xxxxxxx/_git/XXXXXXMobile/pullrequest/23232
2024-09-06T21:30:39.7910050Z Traceback (most recent call last):
2024-09-06T21:30:39.7910752Z File "/app/pr_agent/git_providers/init.py", line 57, in get_git_provider_with_context
2024-09-06T21:30:39.7911346Z git_provider = _GIT_PROVIDERSprovider_id
2024-09-06T21:30:39.7911657Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7912019Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 56, in init
2024-09-06T21:30:39.7912306Z self.set_pr(pr_url)
2024-09-06T21:30:39.7912781Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 190, in set_pr
2024-09-06T21:30:39.7913545Z self.workspace_slug, self.repo_slug, self.pr_num = self._parse_pr_url(pr_url)
2024-09-06T21:30:39.7914480Z ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7914648Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 554, in _parse_pr_url
2024-09-06T21:30:39.7914831Z raise ValueError(
2024-09-06T21:30:39.7914987Z ValueError: The provided URL does not appear to be a Azure DevOps PR URL
2024-09-06T21:30:39.7915079Z
2024-09-06T21:30:39.7915235Z The above exception was the direct cause of the following exception:
2024-09-06T21:30:39.7915323Z
2024-09-06T21:30:39.7915435Z Traceback (most recent call last):
2024-09-06T21:30:39.7915872Z File "/usr/local/bin/pr-agent", line 8, in
2024-09-06T21:30:39.7916017Z sys.exit(run())
2024-09-06T21:30:39.7916119Z ^^^^^
2024-09-06T21:30:39.7916258Z File "/app/pr_agent/cli.py", line 88, in run
2024-09-06T21:30:39.7916399Z result = asyncio.run(inner())
2024-09-06T21:30:39.7916680Z ^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7916821Z File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
2024-09-06T21:30:39.7916976Z return runner.run(main)
2024-09-06T21:30:39.7917100Z ^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7917242Z File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
2024-09-06T21:30:39.7917428Z return self._loop.run_until_complete(task)
2024-09-06T21:30:39.7917554Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7917711Z File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
2024-09-06T21:30:39.7923189Z return future.result()
2024-09-06T21:30:39.7923557Z ^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7924021Z File "/app/pr_agent/cli.py", line 79, in inner
2024-09-06T21:30:39.7924388Z result = await asyncio.create_task(PRAgent().handle_request(args.pr_url, [command] + args.rest))
2024-09-06T21:30:39.7924710Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7925130Z File "/app/pr_agent/agent/pr_agent.py", line 57, in handle_request
2024-09-06T21:30:39.7927571Z apply_repo_settings(pr_url)
2024-09-06T21:30:39.7927884Z File "/app/pr_agent/git_providers/utils.py", line 14, in apply_repo_settings
2024-09-06T21:30:39.7928350Z git_provider = get_git_provider_with_context(pr_url)
2024-09-06T21:30:39.7929310Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:39.7929717Z File "/app/pr_agent/git_providers/init.py", line 62, in get_git_provider_with_context
2024-09-06T21:30:39.7930059Z raise ValueError(f"Failed to get git provider for {pr_url}") from e
2024-09-06T21:30:39.7930844Z ValueError: Failed to get git provider for https://xxxxxxx.visualstudio.com/xxxxxx/_git/XXXXXMobile/pullrequest/23232
2024-09-06T21:30:44.3753730Z Traceback (most recent call last):
2024-09-06T21:30:44.3754552Z File "/app/pr_agent/git_providers/init.py", line 57, in get_git_provider_with_context
2024-09-06T21:30:44.3755148Z git_provider = _GIT_PROVIDERSprovider_id
2024-09-06T21:30:44.3765847Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3766518Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 56, in init
2024-09-06T21:30:44.3766918Z self.set_pr(pr_url)
2024-09-06T21:30:44.3767360Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 190, in set_pr
2024-09-06T21:30:44.3768076Z self.workspace_slug, self.repo_slug, self.pr_num = self._parse_pr_url(pr_url)
2024-09-06T21:30:44.3768444Z ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3768860Z File "/app/pr_agent/git_providers/azuredevops_provider.py", line 554, in _parse_pr_url
2024-09-06T21:30:44.3769229Z raise ValueError(
2024-09-06T21:30:44.3769602Z ValueError: The provided URL does not appear to be a Azure DevOps PR URL
2024-09-06T21:30:44.3769886Z
2024-09-06T21:30:44.3770205Z The above exception was the direct cause of the following exception:
2024-09-06T21:30:44.3770488Z
2024-09-06T21:30:44.3770778Z Traceback (most recent call last):
2024-09-06T21:30:44.3771412Z File "/usr/local/bin/pr-agent", line 8, in
2024-09-06T21:30:44.3771720Z sys.exit(run())
2024-09-06T21:30:44.3772084Z ^^^^^
2024-09-06T21:30:44.3774866Z File "/app/pr_agent/cli.py", line 88, in run
2024-09-06T21:30:44.3775176Z result = asyncio.run(inner())
2024-09-06T21:30:44.3775461Z ^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3775798Z File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
2024-09-06T21:30:44.3777592Z return runner.run(main)
2024-09-06T21:30:44.3777922Z ^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3778320Z File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
2024-09-06T21:30:44.3778785Z return self._loop.run_until_complete(task)
2024-09-06T21:30:44.3779124Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3779524Z File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
2024-09-06T21:30:44.3779911Z return future.result()
2024-09-06T21:30:44.3780174Z ^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3780542Z File "/app/pr_agent/cli.py", line 79, in inner
2024-09-06T21:30:44.3780947Z result = await asyncio.create_task(PRAgent().handle_request(args.pr_url, [command] + args.rest))
2024-09-06T21:30:44.3781349Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3781676Z File "/app/pr_agent/agent/pr_agent.py", line 57, in handle_request
2024-09-06T21:30:44.3782234Z apply_repo_settings(pr_url)
2024-09-06T21:30:44.3783576Z File "/app/pr_agent/git_providers/utils.py", line 14, in apply_repo_settings
2024-09-06T21:30:44.3783813Z git_provider = get_git_provider_with_context(pr_url)
2024-09-06T21:30:44.3783969Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-06T21:30:44.3784170Z File "/app/pr_agent/git_providers/init.py", line 62, in get_git_provider_with_context
2024-09-06T21:30:44.3784404Z raise ValueError(f"Failed to get git provider for {pr_url}") from e
2024-09-06T21:30:44.3784683Z ValueError: Failed to get git provider for https://xxxxxxx.visualstudio.com/xxxxxxx/_git/XXXXXXMobile/pullrequest/23232
2024-09-06T21:30:44.7322094Z
2024-09-06T21:30:44.7371327Z ##[error]Bash exited with code '1'.
2024-09-06T21:30:44.7467460Z ##[section]Finishing: Run PR Agent
The text was updated successfully, but these errors were encountered: