GitHub v3 API isn't able to get commits for a user after their username changed, while it does work on the GitHub UI

When I go to https://api.github.com/repos/nikochiko/double_encode/commits?author=nikochiko, I get 0 results even though I have made commits to that repo with the same account but back when my username was different. However, I’m still able to get the results for it from the UI - https://github.com/nikochiko/double_encode/commits?author=nikochiko.
So GitHub does have the data, but due to some bug in the REST API it isn’t able to show the results correctly.
Note that I even tried running the GitHub API query with ?author=$my_old_username, which was ?author=coldk91ght and I still get an empty response.

That’s an interesting problem. The bug is not just a consequence of your username changing – old commits can be looked up by a new username – but rather a consequence of your email address changing.

The commits were created without a public email address, so GitHub used the GitHub noreply email address associated with your account – 37668193+coldk91ght@users.noreply.github.com – for the commit author details, however, because your username has changed this is no longer your account’s email address… so GitHub can no longer associate these commits with your account.

(You can find the email options in your settings, “Keep my email addresses private”)

I believe the bug can be described as: If you have your email address hidden, and you change your username, then old commits are not associated with the new username because the resolution logic looks for a current email address (verified + private). I think the fix would be for the email lookup portion of author resolution to ignore the +username part of the private email address (presumably, the frontend has this extra step in the logic).

{
   "commit":{
      "author":{
         "name":"coldk91ght",
         "email":"37668193+coldk91ght@users.noreply.github.com",
         "date":"2018-12-22T09:01:37Z"
      },
      "committer":{
         "name":"GitHub",
         "email":"noreply@github.com",
         "date":"2018-12-22T09:01:37Z"
      }
   }
}

That’s my guess, anyway :slight_smile:

What you’re saying makes sense. But it doesn’t explain why even searching with the private email does not work. Something like - https://api.github.com/repos/nikochiko/double_encode/commits?author=37668193+coldk91ght@users.noreply.github.com.