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

Running on Azure DevOps Pipeline error #1200

Open
rethink-danielmohr opened this issue Sep 6, 2024 · 11 comments
Open

Running on Azure DevOps Pipeline error #1200

rethink-danielmohr opened this issue Sep 6, 2024 · 11 comments

Comments

@rethink-danielmohr
Copy link

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

@mrT23
Copy link
Collaborator

mrT23 commented Sep 7, 2024

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

@rethink-danielmohr
Copy link
Author

rethink-danielmohr commented Sep 7, 2024 via email

@MikesHorcrux
Copy link

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 visualstudio.com format, raising a ValueError that the URL is not a valid Azure DevOps PR URL. Azure DevOps supports both dev.azure.com and visualstudio.com formats, but the PR Agent seems to only handle the dev.azure.com format.

Error Message:

Traceback (most recent call last):
  File "/app/pr_agent/git_providers/__init__.py", line 57, in get_git_provider_with_context
    git_provider = _GIT_PROVIDERS[provider_id](pr_url)
  File "/app/pr_agent/git_providers/azuredevops_provider.py", line 56, in __init__
    self.set_pr(pr_url)
  File "/app/pr_agent/git_providers/azuredevops_provider.py", line 190, in set_pr
    self.workspace_slug, self.repo_slug, self.pr_num = self._parse_pr_url(pr_url)
  File "/app/pr_agent/git_providers/azuredevops_provider.py", line 548, in _parse_pr_url
    raise ValueError("The provided URL does not appear to be a Azure DevOps PR URL")
ValueError: The provided URL does not appear to be a Azure DevOps PR URL

Steps to Reproduce:

  1. Set up the PR Agent to run on an Azure DevOps repository.
  2. Use a PR URL in the following format:
    https://{organization}.visualstudio.com/{project}/_git/{repository}/pullrequest/{id}
    
  3. Run the PR Agent to process the PR, which results in the error shown above.

Expected Behavior:

The PR Agent should be able to handle both Azure DevOps URL formats:

  • https://dev.azure.com/{organization}/{project}/_git/{repository}/pullrequest/{id}
  • https://{organization}.visualstudio.com/{project}/_git/{repository}/pullrequest/{id}

Actual Behavior:

The PR Agent raises a ValueError stating that the provided URL does not appear to be a valid Azure DevOps PR URL when using the visualstudio.com format.

Potential Cause:

The issue appears to be in the _parse_pr_url method in azuredevops_provider.py. The current logic may not account for URLs using the visualstudio.com format, resulting in the failure to recognize these URLs as valid.

Possible Fix:

Im not totaly sure but... Modify the _parse_pr_url function to support both visualstudio.com and dev.azure.com URL formats. For example, using a regex to match both formats:

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 visualstudio.com URL into the dev.azure.com format before passing it to the PR Agent. However, this isn't ideal and would require modifying pipeline scripts.

Environment:

  • PR Agent version: latest
  • Azure DevOps URL format: https://{organization}.visualstudio.com/{project}/_git/{repository}/pullrequest/{id}

All in all I really want to implement this tool so would love some help.

@mrT23
Copy link
Collaborator

mrT23 commented Sep 10, 2024

@MikesHorcrux
Try first, from CLI, this PR:
#1216

make sure to properly change your organization:

[azure_devops]
org = "https://dev.azure.com/YOUR_ORGANIZATION/"

to

[azure_devops]
org = "https://{organization}.visualstudio.com/"

if it works, it can be merged to production

@MikesHorcrux
Copy link

@mrT23 Ill test this after its merged in when do you think this will be approved

@mrT23
Copy link
Collaborator

mrT23 commented Sep 11, 2024

@MikesHorcrux
No.
i wont merge something if i am not sure it works. and i dont have access to azure with the
org = "https://{organization}.visualstudio.com/" format

checkout the branch, run it via CLI, and give feedback if it works, or not. that is the path for merging

@rethink-danielmohr
Copy link
Author

@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
PR_URL="https://dev.azure.com/${SYSTEM_TEAMPROJECT}/${SYSTEM_TEAMPROJECT}/_git/${BUILD_REPOSITORY_NAME}/pullrequest/${SYSTEM_PULLREQUEST_PULLREQUESTID}"
echo "PR_URL=$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:

image

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.

            print(self.repo_slug)
            print(self.pr_num)
            print(self.workspace_slug)
            print(iteration_id)

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?

@mrT23
Copy link
Collaborator

mrT23 commented Sep 11, 2024

additional_properties

item = change.additional_properties.get('item', {})

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).
Catch a breakpoint there, and see if there is an easy fix, or if more through adjustments are need.

@danstis
Copy link
Contributor

danstis commented Sep 30, 2024

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 /test.py, when the PR-Agent processes the PR with any operation (describe, improve, review, etc.) it will always return an error like:

2024-09-30 06:07:22.420 | ERROR    | pr_agent.git_providers.azuredevops_provider:get_diff_files:378 - Failed to get diff files, error: "'additional_properties'"
Traceback (most recent call last):

  File "/app/pr_agent/git_providers/azuredevops_provider.py", line 340, in get_diff_files
    original_file_content_str = self.azure_devops_client.get_item(
                                │    │                   └ <function GitClientBase.get_item at 0x7f0af3820f40>
                                │    └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
                                └ <pr_agent.git_providers.azuredevops_provider.AzureDevopsProvider object at 0x7f0af38f7230>

  File "/usr/local/lib/python3.12/site-packages/azure/devops/v7_0/git/git_client_base.py", line 827, in get_item
    response = self._send(http_method='GET',
               │    └ <function Client._send at 0x7f0af3b349a0>
               └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
  File "/usr/local/lib/python3.12/site-packages/azure/devops/client.py", line 104, in _send
    response = self._send_request(request=request, headers=headers, content=content, media_type=media_type)
               │    │                     │                │                │                   └ 'application/json'
               │    │                     │                │                └ None
               │    │                     │                └ {'Content-Type': 'application/json; charset=utf-8', 'Accept': 'application/json;api-version=7.0', 'X-TFS-FedAuthRedirect': 'S...
               │    │                     └ <ClientRequest [GET]>
               │    └ <function Client._send_request at 0x7f0af3b342c0>
               └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
  File "/usr/local/lib/python3.12/site-packages/azure/devops/client.py", line 68, in _send_request
    self._handle_error(request, response)
    │    │             │        └ <Response [404]>
    │    │             └ <ClientRequest [GET]>
    │    └ <function Client._handle_error at 0x7f0af3b34fe0>
    └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
  File "/usr/local/lib/python3.12/site-packages/azure/devops/client.py", line 270, in _handle_error
    raise AzureDevOpsServiceError(wrapped_exception)
          │                       └ <azure.devops._models.WrappedException object at 0x7f0af38fd970>
          └ <class 'azure.devops.exceptions.AzureDevOpsServiceError'>

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.

@CoryBall
Copy link
Contributor

CoryBall commented Oct 8, 2024

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 /test.py, when the PR-Agent processes the PR with any operation (describe, improve, review, etc.) it will always return an error like:

2024-09-30 06:07:22.420 | ERROR    | pr_agent.git_providers.azuredevops_provider:get_diff_files:378 - Failed to get diff files, error: "'additional_properties'"
Traceback (most recent call last):

  File "/app/pr_agent/git_providers/azuredevops_provider.py", line 340, in get_diff_files
    original_file_content_str = self.azure_devops_client.get_item(
                                │    │                   └ <function GitClientBase.get_item at 0x7f0af3820f40>
                                │    └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
                                └ <pr_agent.git_providers.azuredevops_provider.AzureDevopsProvider object at 0x7f0af38f7230>

  File "/usr/local/lib/python3.12/site-packages/azure/devops/v7_0/git/git_client_base.py", line 827, in get_item
    response = self._send(http_method='GET',
               │    └ <function Client._send at 0x7f0af3b349a0>
               └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
  File "/usr/local/lib/python3.12/site-packages/azure/devops/client.py", line 104, in _send
    response = self._send_request(request=request, headers=headers, content=content, media_type=media_type)
               │    │                     │                │                │                   └ 'application/json'
               │    │                     │                │                └ None
               │    │                     │                └ {'Content-Type': 'application/json; charset=utf-8', 'Accept': 'application/json;api-version=7.0', 'X-TFS-FedAuthRedirect': 'S...
               │    │                     └ <ClientRequest [GET]>
               │    └ <function Client._send_request at 0x7f0af3b342c0>
               └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
  File "/usr/local/lib/python3.12/site-packages/azure/devops/client.py", line 68, in _send_request
    self._handle_error(request, response)
    │    │             │        └ <Response [404]>
    │    │             └ <ClientRequest [GET]>
    │    └ <function Client._handle_error at 0x7f0af3b34fe0>
    └ <azure.devops.v7_0.git.git_client.GitClient object at 0x7f0af38fc110>
  File "/usr/local/lib/python3.12/site-packages/azure/devops/client.py", line 270, in _handle_error
    raise AzureDevOpsServiceError(wrapped_exception)
          │                       └ <azure.devops._models.WrappedException object at 0x7f0af38fd970>
          └ <class 'azure.devops.exceptions.AzureDevOpsServiceError'>

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
#1275
#1274

@rethink-danielmohr
Copy link
Author

This seems to work with the latest pushes. Thanks. You guys can close this one.

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

No branches or pull requests

5 participants