Inconsistent handling of moved repositories using API v4 #24517
-
It seems the GraphQL API returns new repository location information only if the former location’s user still exists. For instance, using my browser, I can access old repositories and be redirected to the new location: https://github.com/jim/carmen → https://github.com/carmen-ruby/carmen http://github.com/mjijackson/rack-accept → https://github.com/mjackson/rack-accept Which would indicate in both cases the moving of the repository has been done “properly” (e.g. not by creating a brand new user and git push there), allowing Github to know where to redirect to. However in GraphQL the handling is different:
↓
↓
I assume this is a known limitation? Are there any plans to make this more consistent? With the current situation I have to fallback to the v3 API just for such cases, sending more requests than it should be and having to maintain this extra logic… |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments
-
Thanks for reaching out. I’ve passed this along to the developers who are investigating. We’ll update you when we get more information. Thanks for letting us know! |
Beta Was this translation helpful? Give feedback.
-
@lee-dohm any update on this? It’s been a year now and as far as I can tell, this is still an issue. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, no, there have been no updates on this. |
Beta Was this translation helpful? Give feedback.
-
Bummer. I’ll retry in 2021… |
Beta Was this translation helpful? Give feedback.
-
You should not be using the |
Beta Was this translation helpful? Give feedback.
-
I’m not sure I understand, how do you get a repo id in the first place? The only info I have at my disposal to query is the repo owner and repo name, however outdated those may be. |
Beta Was this translation helpful? Give feedback.
-
Say you have some repositories you want to track based on the slug.
with variables
which return
if the repositories are ever renamed or transferred you can always get the new location through
and query variables
for the following payload
That should get you what you want moving forward. If you just need to get the “redirect” so you can adapt the code to use the global node ID you can use any HTTP library to get the redirect; no need to use the GitHub API for that. For example using HTTP.jl,
Let me know if that helps. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the thorough reply! The problem I face though is I have no control whatsoever of the owner/repo name pairs I’m going to get. And while the v3 API handles just fine moved repos, the issue here is v4 falls flat on its face in the one case where a repo moved and the former owner account doesn’t exist anymore.
This is definitely a bug affecting the GraphQL API and it’s a shame it’s been sitting on the back burner for more than a year. |
Beta Was this translation helpful? Give feedback.
-
The solution is use the global node ID which is the recommended practice for all resources that one has to query subsequently. When passing the repository by owner/name it first has to do a scan to find the node ID which incurs in wasteful computing and time. I would probably first do a GET request to get the latest slug for the repo and right after get the global node (you could do it with the GitHub RESTful v3 API as well and get the node ID from that call too). Remember that the limits for the REST and GraphQL API are separate so doing a few REST API calls does not affect your GraphQL remaining points. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your patience folks, this should now be fixed. |
Beta Was this translation helpful? Give feedback.
-
Do you mean fixed and released or fixed and soon-to-be-released? Because I still get the same error I described in the original post. |
Beta Was this translation helpful? Give feedback.
-
It seems it now redirects on the name so it will work for
but still errors out if the owner changed the name
with
yields
Would be good if the “fix” could be extended to redirect usernames by login and consequently fully match the HTTP GET behavior. |
Beta Was this translation helpful? Give feedback.
-
The fix deployed yesterday, I’ve just ran the query and you are absolutely correct. Let me talk to the team. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your patience @nosferican, turns out we had to revert this change due to some other issues. The team is working on a fix to ship this once again, I’ll keep you posted here. |
Beta Was this translation helpful? Give feedback.
-
Will be working on an application for which it would be wonderful to have this functionality by then… I will probably get to it around mid August. |
Beta Was this translation helpful? Give feedback.
-
Hi @nosferican give this a go please, it should be okay now as the latest fix has been deployed 🤞t4: |
Beta Was this translation helpful? Give feedback.
-
Confirmed it’s fixed so marking this as resolved. Thanks for following up @AndreaGriffiths11 !!! |
Beta Was this translation helpful? Give feedback.
Hi @nosferican give this a go please, it should be okay now as the latest fix has been deployed 🤞t4: