JuliusBrussee/caveman · error
githubapp: exactly one repository is required
Error message
githubapp: exactly one repository is required
What it means
Validation in MintInstallationToken(): the repos slice must contain exactly one non-empty repository name. Token minting is deliberately narrowed to a single repo (least-agency); zero, multiple, or blank repo names are rejected before any network call.
Source
Thrown at shared/platform/githubapp/githubapp.go:192
if err := json.Unmarshal(raw, &out); err != nil {
return out, fmt.Errorf("githubapp: decode installation: %w", err)
}
if out.ID != installationID || out.Account.ID <= 0 || strings.TrimSpace(out.Account.Login) == "" {
return Installation{}, fmt.Errorf("githubapp: installation response identity mismatch")
}
return out, nil
}
// MintInstallationToken POSTs /app/installations/{id}/access_tokens narrowed to
// `repos` and `perms`, returning a ~1h token. Defaults (perms nil) are
// contents:write + pull_requests:write — enough to push a branch and open a draft
// PR, never to merge.
func (a *App) MintInstallationToken(ctx context.Context, installationID int64, repos []string, perms map[string]string) (InstallationToken, error) {
if installationID <= 0 {
return InstallationToken{}, fmt.Errorf("githubapp: installation id must be positive")
}
if len(repos) != 1 || strings.TrimSpace(repos[0]) == "" {
return InstallationToken{}, fmt.Errorf("githubapp: exactly one repository is required")
}
repository := strings.TrimSpace(repos[0])
if perms == nil {
perms = map[string]string{"contents": "write", "pull_requests": "write"}
}
allowedPermissions := map[string]bool{"contents": true, "pull_requests": true}
scopedPermissions := make(map[string]string, len(perms))
for name, level := range perms {
if !allowedPermissions[name] || (level != "read" && level != "write") {
return InstallationToken{}, fmt.Errorf("githubapp: permission %q=%q exceeds the least-agency allowlist", name, level)
}
scopedPermissions[name] = level
}
jwt, err := a.AppJWT()
if err != nil {
return InstallationToken{}, err
}
body := map[string]any{"permissions": scopedPermissions, "repositories": []string{repository}}View on GitHub (pinned to 766dce6b13)
Solutions
- Pass exactly one fully-qualified repository (owner/name) from the verified repo-selection step
- If multiple repos are needed, mint one token per repo rather than widening the scope
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/platform/githubapp/githubapp.go:192 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/4f226d5c1744202f.
Report an issue: GitHub.