Skip to content

gh: listInstallations / listAppsInstalledRepo call the GitHub API twice on every cache miss #268

Description

@whywaita

Problem

Both cache wrappers in pkg/gh/installation.go fetch the data, store it in the cache, and then fetch it again for the return value:

inst, err := _listInstallations(ctx)
if err != nil { ... }

responseCache.Set(getCacheInstallationsKey(), inst, 1*time.Hour)

return _listInstallations(ctx)   // pkg/gh/installation.go:24 — second full API call (paginated!)

Same pattern in listAppsInstalledRepo (pkg/gh/installation.go:70). Every cache miss therefore costs 2× the API requests (each call paginates through all installations/repos at 100 per page), doubling rate-limit consumption for no benefit. Note the second call's error is also returned unwrapped, bypassing the wrapper's error message.

Suggested fix

return inst, nil

(and return repos, nil in listAppsInstalledRepo).

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions