{"record":{"id":"453b0567d4141f0d","repo":"JuliusBrussee/caveman","slug":"githubapp-installation-response-identity-mismatch","errorCode":null,"errorMessage":"githubapp: installation response identity mismatch","messagePattern":"githubapp: installation response identity mismatch","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":178,"sourceCode":"\t\treturn out, fmt.Errorf(\"githubapp: installation id must be positive\")\n\t}\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\"/app/installations/\"+strconv.FormatInt(installationID, 10), 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 installation: HTTP %d: %s\", status, snippet(raw))\n\t}\n\tif err := json.Unmarshal(raw, &out); err != nil {\n\t\treturn out, fmt.Errorf(\"githubapp: decode installation: %w\", err)\n\t}\n\tif out.ID != installationID || out.Account.ID <= 0 || strings.TrimSpace(out.Account.Login) == \"\" {\n\t\treturn Installation{}, fmt.Errorf(\"githubapp: installation response identity mismatch\")\n\t}\n\treturn out, nil\n}\n\n// MintInstallationToken POSTs /app/installations/{id}/access_tokens narrowed to\n// `repos` and `perms`, returning a ~1h token. Defaults (perms nil) are\n// contents:write + pull_requests:write — enough to push a branch and open a draft\n// PR, never to merge.\nfunc (a *App) MintInstallationToken(ctx context.Context, installationID int64, repos []string, perms map[string]string) (InstallationToken, error) {\n\tif installationID <= 0 {\n\t\treturn InstallationToken{}, fmt.Errorf(\"githubapp: installation id must be positive\")\n\t}\n\tif len(repos) != 1 || strings.TrimSpace(repos[0]) == \"\" {\n\t\treturn InstallationToken{}, fmt.Errorf(\"githubapp: exactly one repository is required\")\n\t}\n\trepository := strings.TrimSpace(repos[0])\n\tif perms == nil {\n\t\tperms = map[string]string{\"contents\": \"write\", \"pull_requests\": \"write\"}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/shared/platform/githubapp/githubapp.go#L160-L196","documentation":"Security check in GetInstallation(): GitHub's response does not match the requested identity — the returned installation id differs from the requested one, or the account id/login is missing. This fails closed against spoofed or inconsistent responses during callback validation.","triggerScenarios":"Thrown at shared/platform/githubapp/githubapp.go:178 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as an authorization failure: do not trust the supplied installation id; re-run the connect flow","Investigate if this recurs, as it indicates API responses not matching requests (proxy/tampering or id confusion)"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}