Unable to access GitHub repository - Error 404/422
404 - Not Found
You may see the following error whilst connecting to your GitHub repository using the oAuth method.
GET https://api.github.com/repos/org-slug/repo-slug/keys?per_page=100: 404 - Not Found // See: https://docs.github.com/rest/reference/repos#list-deploy-keys
This error usually means the user you're connected as, does not have admin access to the repository you're trying to add. Further details on permissions can be found here.
422 - Validation Failed
Alternatively, if you see the following error:
POST https://api.github.com/repos/org-slug/repo-slug/keys: 422 - Validation Failed
Error summary:
resource: PublicKey
code: custom
field: key
message: key is already in use // See: https://docs.github.com/rest/reference/repos#create-a-deploy-key
This would mean your project's public key, already exists within the repository.
And the following would mean the project's webhook already exists in the repository:
POST https://api.github.com/repos/org-slug/repo-slug/hooks: 422 - Validation Failed
Error summary:
resource: Hook
code: custom
message: Hook already exists on this repository // See: https://docs.github.com/rest/reference/repos#create-a-repository-webhook
You could manually remove this and try adding the repository again, or alternatively, you could add the repository manually.