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

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

Closed
jbrangwyn opened this issue Mar 10, 2021 · 9 comments
Closed

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

jbrangwyn opened this issue Mar 10, 2021 · 9 comments

Comments

@jbrangwyn
Copy link

jbrangwyn commented Mar 10, 2021

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link

Sean-Steefel commented Mar 17, 2021

@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
Copy link
Owner

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
Copy link

ghost commented Mar 29, 2021

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
Copy link
Owner

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
Copy link
Owner

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
Copy link

Sean-Steefel commented Apr 3, 2021 via email

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

3 participants