Skip to content

Conversation

@Iamrodos
Copy link
Contributor

Fixes #198 - Fix case-sensitive username filtering

GitHub's API accepts usernames in any case (e.g., prai-org, PRAI-Org, PrAi-OrG) but always returns the canonical case in the response. When you type a username with different casing than GitHub's canonical form, the tool's case-sensitive string comparison causes all repositories to be filtered out.

How to reproduce:

The tool calls /user/repos which returns all repos the authenticated user has access to. GitHub accepts any case in the command line argument but returns the canonical case in the response:

curl -s -H "Authorization: token $TOKEN" https://api.github.com/user/repos | jq '.[0]'

# Returns repos with canonical case in owner.login:
{
  "name": "AdventOfCode",
  "owner": {
    "login": "Iamrodos"  // Capital I - canonical case from GitHub
  }
}

As the filer compares "Iamrodos" == "iamrodos" the result is false.

The bug:

At github_backup/github_backup.py:1590, the code does exact string matching:

if r.get("owner", {}).get("login") == args.user or r.get("is_starred"):

Since GitHub's API is not case-sensitive for usernames, the tool's filter shouldn't be either.

History:

This bug was introduced in commit d362adb (January 2016) when the tool switched from /users/{user}/repos to /user/repos for private repository access. The /user/repos endpoint returns all repos the authenticated user can see (including organization repos), requiring filtering by owner. The filter comparison was inadvertently made case-sensitive.

Fix:

Changed the comparison to be case-insensitive:

owner_login = r.get("owner", {}).get("login", "")
if owner_login.lower() == args.user.lower() or r.get("is_starred"):

Tested with multiple repos using lowercase, uppercase, and mixed case usernames.

GitHub's API accepts usernames in any case but returns canonical case.
The case-sensitive comparison in filter_repositories() filtered out all
repositories when user-provided case didn't match GitHub's canonical case.

Changed to case-insensitive comparison.

Fixes josegonzalez#198
@josegonzalez josegonzalez merged commit 745b05a into josegonzalez:master Nov 30, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Github-backup in 140 repository org backups nothing

2 participants