Skip to content

git: Use CDN endpoint for GitHub avatars to avoid rate limiting#47894

Merged
cole-miller merged 1 commit intozed-industries:mainfrom
Augani:fix/github-avatar-rate-limiting
Jan 31, 2026
Merged

git: Use CDN endpoint for GitHub avatars to avoid rate limiting#47894
cole-miller merged 1 commit intozed-industries:mainfrom
Augani:fix/github-avatar-rate-limiting

Conversation

@Augani
Copy link
Contributor

@Augani Augani commented Jan 28, 2026

GitHub's commit API endpoint is rate limited to 60 requests/hour for unauthenticated users. This causes avatar loading to fail after toggling blame a few times.

This PR uses GitHub's CDN avatar endpoint https://avatars.githubusercontent.com/u/e?email={email}&s=128 instead, which doesn't count against API rate limits. The author email is already available from local git data (blame output), so
no API calls are needed.

  • When author email is available, constructs the CDN URL directly (zero API calls)
  • Falls back to existing API-based behavior when email is unavailable
  • Adds unit tests for URL construction

Closes #47590

Test plan

  • ./script/clippy passes
  • cargo test -p git_hosting_providers passes (89 tests including 3 new ones i added)
  • Manual test: Open a file, toggle git blame, verify avatars load without hitting rate limits

Release Notes:

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 28, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jan 28, 2026
@Augani Augani marked this pull request as ready for review January 28, 2026 19:25
@cole-miller
Copy link
Member

Thanks!

@cole-miller cole-miller enabled auto-merge (squash) January 29, 2026 15:12
GitHub's commit API endpoint is rate-limited to 60 requests/hour for
unauthenticated users. This causes avatar loading to fail after a few
blame toggles.

This change uses GitHub's CDN avatar endpoint
`https://avatars.githubusercontent.com/u/e?email={email}&s=128`
which doesn't count against API rate limits. The author email is already
available from local git data, so no API calls are needed.

Closes zed-industries#47590
auto-merge was automatically disabled January 29, 2026 16:17

Head branch was pushed to by a user without write access

@Augani Augani force-pushed the fix/github-avatar-rate-limiting branch from 79ead01 to d1cfd3f Compare January 29, 2026 16:17
@cole-miller cole-miller merged commit 36e35f7 into zed-industries:main Jan 31, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hitting github's public api rate limit when displaying avatars

2 participants