cribeiro84 / azure-devops-pull-request-hub

Azure DevOps Pull Request Manager Hub
MIT License
59 stars 35 forks source link

Error TFS.WebApi.Exception: TF401019 when disabling a git repo #170

Closed jbrangwyn closed 3 years ago

jbrangwyn commented 3 years ago

Firstly, thanks for making a nice extension that I use often :)

In AzureDevOps (cloud) we have disabled several repos and now get the following error when loading the pull request manager:

There was an error during the extension load: TFS.WebApi.Exception: TF401019: The Git repository with name or identifier 64BBDBD3-76B8-4B12-9365-18E1CA00343F does not exist or you do not have permissions for the operation you are attempting.

And it no longer shows any pull requests (for any project/repo).

On the network tab, I can see the Azure API is responding with a 404: {$id: "1", innerException: null,…} $id: "1" errorCode: 0 eventId: 3000 innerException: null message: "TF401019: The Git repository with name or identifier XXXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX does not exist or you do not have permissions for the operation you are attempting." typeKey: "GitRepositoryNotFoundException" typeName: "Microsoft.TeamFoundation.Git.Server.GitRepositoryNotFoundException, Microsoft.TeamFoundation.Git.Server"

cribeiro84 commented 3 years ago

Hi @jbrangwyn thanks for the nice feedback! We really appreciate it.

With regards the error, it seems related yet to permissions in your project or across projects acesses. The APIs are consumed following the standards of ADO. Have you tried to see which repo is that and what are the permissions you have on it?

Thanks a lot

jbrangwyn commented 3 years ago

I know what you mean about permissions, but I think it's more of an API and response handling issue...

The extension successfully gets a list of all the repos, which suggests there isn't a permissions issue - it also works fine when all the repo's are enabled. But when disabling a repo, it still successfully gets a list of all the repos then attempts to query the API to get the status of the pull requests and it's at this point the API responds with a 404 because the repo is disabled (the error appears to be a 'not found' exception, but it has to have found it to be querying it in the first place!).

I can think of two ways of resolving it - not including the disabled repos in the initial call to get the list of repos (from a quick look, you should be able to change the API call to: Repositories?includeLinks=true&deleted=false Or alternatively, handle the 404 error more gracefully and still display the pull requests for the repos it could find.

cribeiro84 commented 3 years ago

Hi @jbrangwyn thanks fo rthe details. I use the npm library available from Azure DevOps team (https://github.com/microsoft/azure-devops-extension-api) to fetch the repos, PRs and some other details. It doesn't have any option to deleted repos and by default it does not include "hidden" repos.

https://github.com/microsoft/azure-devops-extension-api/blob/bd06868b78a14b3840823b393f6fe3378b2be59d/src/Git/GitClient.ts#L3449

Sean-Steefel commented 3 years ago

@cribeiro84 more info -- this is now also happening for internal MS instances of ADO. image More info... the ADO API's now return this on data list request of Repositories:

{

"id":  "{REDACTED}",
"name":  "{REDACTED}",
"url":  "https://dev.azure.com/{REDACTED}/{REDACTED}/_apis/git/repositories/{REDACTED}",
"project":  {
                "id":  "{REDACTED}",
                "name":  "Development {REDACTED}",
                "description":  "This project will contain source code and related documents for {REDACTED} tools. ",
                "url":  "https://dev.azure.com/{REDACTED}/_apis/projects/{REDACTED}",
                "state":  "wellFormed",
                "revision":  787,
                "visibility":  "organization",
                "lastUpdateTime":  "2021-01-18T20:21:00.11Z"
            },
"defaultBranch":  "refs/heads/master",
"size":  27784861,
"remoteUrl":  "https://{REDACTED}@dev.azure.com/{REDACTED}/{REDACTED}/_git/CMT{REDACTED}Automation",
"sshUrl":  "git@ssh.dev.azure.com:v3/{REDACTED}/{REDACTED}/CMT{REDACTED}Automation",
"webUrl":  "https://dev.azure.com/{REDACTED}/{REDACTED}/_git/CMT{REDACTED}Automation",
"isDisabled":  false

}

NOTE: the isDisabled property - if true then the repository is not accessible.

cribeiro84 commented 3 years ago

Hi @Sean-Steefel - I will check if the response from the API brings the isDisabled property so we can handle it within the code instead of the filtering in the API. Thanks for bringing this information.

ghost commented 3 years ago

I'm getting the same issue, the point is, I'm Project Collection Admin, so I don't believe it's about permissions, and I tried to find the refered repository, and it's nowhere.

If you have any news on this, it would be very helpful. This error rended the whole extension useless.

cribeiro84 commented 3 years ago

I indeed have news about it. This is an issue when you have disabled repos which causes all related APIs (PRs, Repo details, so on) to fail with "permission exception". As a reference, check the below image:

image

So as a temporary solution, you should re-enable the repo(s) or permanently delete it or wait for a fix. I'm already working on it but I don't have a solution yet once the API of ADO extension does not allow to filter disabled repos and also its entities from Git don't have the isDisabled property.

cribeiro84 commented 3 years ago

A new version is released with this fix. Could you please test it? Feel free to reopen the issue in case it's still not working.

Sean-Steefel commented 3 years ago

Its working again! I like that you simply hide the disabled repo's - Thanks!

From: Carlos Alessandro Ribeiro @.> Sent: Friday, April 2, 2021 6:07 PM To: cribeiro84/azure-devops-pull-request-hub @.> Cc: Sean Steefel (Valorem LLC) @.>; Mention @.> Subject: Re: [cribeiro84/azure-devops-pull-request-hub] Error TFS.WebApi.Exception: TF401019 when disabling a git repo (#170)

A new version is released with this fix. Could you please test it? Feel free to reopen the issue in case it's still not working.

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcribeiro84%2Fazure-devops-pull-request-hub%2Fissues%2F170%23issuecomment-812760734&data=04%7C01%7Cv-sestee%40microsoft.com%7C409519a89ef541fd15c208d8f63478fa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637530052520224010%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=MQ7BHqCWVIdbwup56eYFTxjqVjeg8x6pDUMLN%2FxlKK0%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARSPFES7SBHBSVWJIF4DRLLTGZL4DANCNFSM4Y6LXGPQ&data=04%7C01%7Cv-sestee%40microsoft.com%7C409519a89ef541fd15c208d8f63478fa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637530052520234001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=cOqZm1RHZCeNolr5%2FUw8Adt1GLAyFQNtKY%2Fttec%2B%2FXw%3D&reserved=0.

dariusz-bzowka-chain-insight commented 2 months ago

I'm getting the error anyway. When I try disable repo it return: TFS.WebApi.Exception: 500: