GitHub App can't access private repository "This could be because the repository is empty or disabled."

When I try to create a new site from GitHub using one of my Org’s private repos. I occasionally get the same problem listed by another community member here

However, when I get past that problem I see: “We couldn’t access the repository {ORG/repo-name}. This could be because the repository is empty or disabled.”

  • It is neither empty, disabled.
  • Netlify is in the “Installed GitHub Apps” list for the Org.
  • It is configured with proper Permissions and access to all Repositories.
  • There are no Third-party application access policies in place by the Org

The http request that fails in the browser is to:
https://api.github.com/repos/ORG/repo-name/contents/?ref=master

Response:

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/repos/contents/#get-contents"
}

As a consequence of this error, using the Netlify GitHub App is causing me much more trouble and grief than simply installing and configuring a Deploy key :frowning:

I also need help to “make a new drag and drop site (create a new site not linked to git), configured the “old way”, with webhooks and deploy keys” as recommended in the other post. I tried it, and it brought me back to the “GitHub App”, which isn’t doing it for me.

It would be nice to make that option still available in the UX without having to do the drag & drop first. I wasn’t sure it was still possible until I read the suggestion, and even then I can’t find it… Thanks.

hi there, can you tell us which netlify site this is regarding? if we unlink the repo for you, you’ll be able to deploy via drag n drop, does that work for you?

@perry Thanks for the offer. I appreciate the support. However, linking to GitHub via the App is now working!

I’m not sure what changed. I think it was one of those things (either on GitHub or your end) that was broken when I was trying it and is now fixed. Sometimes simply waiting solves the problem instead of hammering away at it. DNS changes are like that. Perhaps authorizing Netlify’s GitHub App took time?

However, I did notice one thing. When I look at the http traffic, I no longer see the failing request to https://api.github.com/repos/ORG/repo-name/contents/...

Instead I see a working request to:

https://api.github.com/repos/ORG/repo-name/branches?page=1&per_page=100

Which by default fills the UI with “master”. This leads me to believe something in the GitHub App code was changed. Obviously for the better :wink:

PS: I was intent on setting up Continuous Deployment due to frequent changes, so a manual deploy was not ideal…

1 Like

makes sense. Glad it is working now!

I had the same problem and spent hours struggling to solve it.

In my case I deleted the netlify.toml file and this solved the problem.

This is the file containing the netlify.toml file:

# [[redirects]]
#  from = "https://example.netlify.app"
#  to = "https://example.com"
#  status = 301
#  force = true

# [[redirects]]
#  from = "https://example.netlify.app/*"
#  to = "https://example.com/:splat"
#  status = 301
#  force = true

[[headers]]
 for = "https://example.netlify.app/*"
 [headers.values]
   X-Robots-Tag: "noindex" 

I don’t know the exact cause of this problem, I’m new to Netlify.

I suspect that the "for = “https://example.netlify.app/*” line is problematic because this is a newly deployed site, of course, it doesn’t have a domain yet.

Who knows, this solution could be of use to other users who are experiencing a similar problem.

1 Like

Thanks for sharing you solution with the thread, @Renova_Muhamad_Reza :slight_smile: Like you said, it will definitely be useful to future Forums members who encounter something similar.