'TF401019: The Git repository with name or identifier public does not exist or you do not have permissions for the operation you are attempting

I have two ADO repositories named private2 and public2. private2 references public2 as a submodule:

enter image description here

I also added a yaml file (vsts-cicd.yml) for build as follows:

resources:
  repositories:
  - repository: test
    type: git
    name: <ProjectName>/public2
    ref: master

stages:

- template: build1.yml@test
  parameters:
    repoToCheckout: test
    checkoutPath: '$(Build.BuildNumber)'

- template: build2.yml@test
  parameters:
    repoToCheckout: test
    checkoutPath: '$(Build.BuildNumber)'
    
- template: yaml/build3.yml

On running the build, I see the first two templates completed successfully. On reaching - template: yaml/build3.yml it fails with the following error:

enter image description here

What am I missing?

UPDATE:

I followed this article (https://www.timschaeps.be/post/dealing-with-error-tf401019-submodules-azure-pipelines/) to fix the issue however I don’t see this option in project settings: ‘Limit job authorization scope to referenced Azure DevOps repositories’. What am I missing?

enter image description here



Solution 1:[1]

I've faced this issue recently. For me it was using wrong credentials from windows credential manager. Permission on my repository was revoked for the credentials stored. So I removed the obsolete credential and cloned again. It worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Md. Sojib Miya