{"record":{"id":"f77727d0bc8e6c06","repo":"JuliusBrussee/caveman","slug":"githubapp-get-repo-installation-s-s-http-d","errorCode":null,"errorMessage":"githubapp: get repo installation %s/%s: HTTP %d: %s","messagePattern":"githubapp: get repo installation (.+?)/(.+?): HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":285,"sourceCode":"\treturn r, nil\n}\n\n// GetRepoInstallation asks GitHub which installation of this App owns access to\n// a repository. This avoids treating public repository visibility as proof that\n// a caller-supplied installation id is authorized for that repository.\nfunc (a *App) GetRepoInstallation(ctx context.Context, owner, name string) (Installation, error) {\n\tvar out Installation\n\tjwt, err := a.AppJWT()\n\tif err != nil {\n\t\treturn out, err\n\t}\n\tstatus, raw, err := a.do(ctx, \"Bearer \"+jwt, http.MethodGet,\n\t\t\"/repos/\"+url.PathEscape(owner)+\"/\"+url.PathEscape(name)+\"/installation\", nil)\n\tif err != nil {\n\t\treturn out, err\n\t}\n\tif status != http.StatusOK {\n\t\treturn out, fmt.Errorf(\"githubapp: get repo installation %s/%s: HTTP %d: %s\", owner, name, status, snippet(raw))\n\t}\n\tif err := json.Unmarshal(raw, &out); err != nil {\n\t\treturn out, fmt.Errorf(\"githubapp: decode repo installation: %w\", err)\n\t}\n\tif out.ID <= 0 {\n\t\treturn Installation{}, fmt.Errorf(\"githubapp: repo installation response carried no id\")\n\t}\n\treturn out, nil\n}\n\n// GetFileContent reads one repository file with an installation token. The\n// content endpoint returns base64; callers receive decoded bytes with a strict\n// 64 KiB post-decode ceiling because connection proofs are tiny text files.\nfunc (a *App) GetFileContent(ctx context.Context, token, owner, name, path, ref string) ([]byte, error) {\n\tsegments := strings.Split(strings.Trim(path, \"/\"), \"/\")\n\tif len(segments) == 0 || segments[0] == \"\" {\n\t\treturn nil, fmt.Errorf(\"githubapp: content path is required\")\n\t}","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/githubapp/githubapp.go#L267-L303","documentation":"GetRepoInstallation asks GitHub which App installation owns access to a repo via GET /repos/{owner}/{name}/installation authenticated with a JWT, expecting HTTP 200. Non-200 statuses produce this error with owner/name, status, and body snippet.","triggerScenarios":"GET /repos/.../installation returns non-200: 404 when the App has no installation covering that repo, 401 when the App JWT is expired or malformed, 403 when the integration is suspended.","commonSituations":"JWT generated with wrong App ID or stale private key (expired after 10 minutes); repo not granted to the App installation; verifying control of a repo the App genuinely cannot access.","solutions":["Regenerate the App JWT just before the call — JWTs are valid only ~10 minutes (check iat/exp claims)","Verify App ID and private key match the App that owns the installation (401)","Confirm in GitHub App settings that the repo/org is included in the installation (404)","On 403 check X-RateLimit headers and integration suspension status, retry after backoff"],"exampleFix":"// before\ninst, err := app.GetRepoInstallation(ctx, owner, name)\nif err != nil { return err }\n// after\ninst, err := app.GetRepoInstallation(ctx, owner, name)\nif err != nil {\n    if strings.Contains(err.Error(), \"HTTP 401\") {\n        return fmt.Errorf(\"app JWT expired — regenerate before calling: %w\", err)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// mint a fresh App JWT (<=10 min exp) immediately before the call\n// verify appID > 0 and privateKey loaded\nif appID == 0 || privateKey == nil { return errors.New(\"app credentials missing\") }","typeGuard":"func isInstallAuthError(err error) bool { return err != nil && strings.Contains(err.Error(), \"HTTP 401\") }","tryCatchPattern":"inst, err := app.GetRepoInstallation(ctx, owner, name)\nif err != nil {\n    if isInstallAuthError(err) { return retryWithFreshJWT() } // regenerate JWT and retry once\n    return err\n}","preventionTips":["Generate the App JWT immediately before each installation lookup (10-minute validity)","Confirm repo/org is in the App installation scope before proof checks","Rotate the private key in sync with GitHub App settings","Handle 403 rate limits with exponential backoff"],"tags":["github","jwt","installation"],"backgroundTag":"jwt-token-expired","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}