Skip to content

GitHub repository discovery spends 2–3 list calls per owner every refresh (GET /user each time, org repos listed twice, 404 for users) #343

Open

Description

@matt-edmondson

What's wrong

UpdateRepositoriesAsync (BuildMonitor/Providers/GitHub.cs ~L229-L286) does the following for every owner on every 300 s refresh:

  • It calls User.Current() only to compare the login with the owner name. The authenticated login does not change between refreshes.
  • For any owner that is not the authenticated user, it calls both GetAllForUser(owner) and GetAllForOrg(owner):
    • For an organization, /users/{org}/repos returns the org's public repos, and /orgs/{org}/repos returns them again along with the private ones. Every public repo is paged through twice, because Octokit's GetAll* reads every page.
    • For a plain user, GetAllForOrg always returns 404, which wastes one request per user per refresh.
  • The GetOrAdd loop then drops the duplicates.

Cost

For an org with 300 public repos, each refresh costs 1 + 3 + 3 = 7 requests instead of 3. That is about 48 extra requests per hour for one owner. With several owners, discovery takes a noticeable share of a budget that #331 and #333 already show is tight.

Suggested fix

  • Cache the authenticated login per token. Read it once and clear it when the token changes.
  • Decide once whether an owner is a user or an organization (/users/{name} returns type), and store the answer on Owner.
  • Then make exactly one paginated list call per refresh:
    • GetAllForCurrent (filtered) for the authenticated user
    • GetAllForOrg for organizations
    • GetAllForUser for other users

Acceptance criteria

  • Discovery for an organization makes one paginated list call per refresh, and no /user call after the first.
  • Discovery for a non-authenticated user makes no /orgs/... call.
  • A test or debug log counts the requests made.

Activity

  1. added
    enhancement
    on Oct 6, 2026
  2. matt-edmondson commented on Oct 6, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions