JuliusBrussee/caveman · error

githubapp: get repo / : HTTP

Error message

githubapp: get repo %s/%s: HTTP %d: %s

What it means

GetRepo fetches repository metadata via GET /repos/{owner}/{name} with an installation token and expects HTTP 200. Any non-200 status produces this error carrying owner/name, status code, and a body snippet.

Solutions

  1. Check the embedded status: 404 means grant the App access to the repo in GitHub App installation settings
  2. Refresh the installation token if 401 — installation tokens expire after about an hour
  3. Verify owner/name spelling and that the repo hasn't been renamed or transferred
  4. Retry on 5xx / 403-with-Retry-After (rate limit) after a backoff

Example fix

// before
repo, err := app.GetRepo(ctx, token, owner, name)
if err != nil { return err }
// after
repo, err := app.GetRepo(ctx, token, owner, name)
if err != nil {
    if strings.Contains(err.Error(), "HTTP 404") {
        return fmt.Errorf("app not installed on %s/%s: %w", owner, name, err)
    }
    return err
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the installation has the repo selected before calling
// (org-level check via GET /installation/repositories listing) or at minimum validate inputs
if owner == "" || name == "" { return errors.New("owner/name required") }

Type guard

func isRepoNotFound(err error) bool { return err != nil && strings.Contains(err.Error(), "HTTP 404") }

Try / catch

repo, err := app.GetRepo(ctx, token, owner, name)
if err != nil {
    if isRepoNotFound(err) { return fmt.Errorf("app lacks access to %s/%s", owner, name) }
    return err
}

Prevention

When it happens

Trigger: GET /repos/... returns non-200: 404 if the App's installation lacks access to the repo, 401 for an expired installation token, 301/307 if the repo was renamed, 403 for blocked access.

Common situations: App installed on an org but the specific repo not selected during installation; token expired (installation tokens last ~1h); repo renamed or transferred between lookups.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/a5ba6c36b0b892d5. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/githubapp/githubapp.go:261

// Repo is the minimal repo metadata the connect flow stores.
type Repo struct {
	ID            int64  `json:"id"`
	NodeID        string `json:"node_id"`
	FullName      string `json:"full_name"`
	DefaultBranch string `json:"default_branch"`
}

// GetRepo verifies that the installation token can see owner/name and returns the
// repo's stable node id + default branch. Used by select-repo to confirm the repo
// truly belongs to the installation before the binding goes 'active'.
func (a *App) GetRepo(ctx context.Context, token, owner, name string) (Repo, error) {
	status, raw, err := a.do(ctx, "Bearer "+token, http.MethodGet,
		"/repos/"+url.PathEscape(owner)+"/"+url.PathEscape(name), nil)
	if err != nil {
		return Repo{}, err
	}
	if status != http.StatusOK {
		return Repo{}, fmt.Errorf("githubapp: get repo %s/%s: HTTP %d: %s", owner, name, status, snippet(raw))
	}
	var r Repo
	if err := json.Unmarshal(raw, &r); err != nil {
		return Repo{}, fmt.Errorf("githubapp: decode repo: %w", err)
	}
	return r, nil
}

// GetRepoInstallation asks GitHub which installation of this App owns access to
// a repository. This avoids treating public repository visibility as proof that
// a caller-supplied installation id is authorized for that repository.
func (a *App) GetRepoInstallation(ctx context.Context, owner, name string) (Installation, error) {
	var out Installation
	jwt, err := a.AppJWT()
	if err != nil {
		return out, err
	}
	status, raw, err := a.do(ctx, "Bearer "+jwt, http.MethodGet,

View on GitHub (pinned to 3ee70a1026)