404 instead of 301 for renamed repository

I’m calling the “Get a repository installation for the authenticated app” endpoint on a Github enterprise installation for a repository that’s been renamed. From the documentation, I’d expect that it would return a 301 pointing to the new URL.

Is this a bug, or is it intended behaviour? If the latter, is there a standard workaround for resolving the moved repository?

:wave: welcome to the GitHub Support Community, @baconator!

The API v3 uses HTTP redirection where appropriate. Given that the example you’ve shared involves a GitHub App installation, that installation can only access resources from repositories that it is installed to. As such, the permissions for that installation can vary: it could be installed to zero, one, many, or all repositories in the organization.

In general, we don’t need to know the quantity of repositories this application is installed to. Given the current behavior, rather than relying on the GitHub REST API to send a redirect for a renamed repository, one approach that you can take is making a request (authenticating with your JWT) to list all the installations for the authenticated application. In that way, you get a (potentially) updated list of repositories’ names and you can cache that for later use when you do fetch that repository installation.

Would such an approach meet your need? :thought_balloon: