{"record":{"id":"ccb88a37132d31a1","repo":"JuliusBrussee/caveman","slug":"githubapp-mint-token-http-d-s","errorCode":null,"errorMessage":"githubapp: mint token: HTTP %d: %s","messagePattern":"githubapp: mint token: HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":217,"sourceCode":"\tscopedPermissions := make(map[string]string, len(perms))\n\tfor name, level := range perms {\n\t\tif !allowedPermissions[name] || (level != \"read\" && level != \"write\") {\n\t\t\treturn InstallationToken{}, fmt.Errorf(\"githubapp: permission %q=%q exceeds the least-agency allowlist\", name, level)\n\t\t}\n\t\tscopedPermissions[name] = level\n\t}\n\tjwt, err := a.AppJWT()\n\tif err != nil {\n\t\treturn InstallationToken{}, err\n\t}\n\tbody := map[string]any{\"permissions\": scopedPermissions, \"repositories\": []string{repository}}\n\tstatus, raw, err := a.do(ctx, \"Bearer \"+jwt, http.MethodPost,\n\t\t\"/app/installations/\"+strconv.FormatInt(installationID, 10)+\"/access_tokens\", body)\n\tif err != nil {\n\t\treturn InstallationToken{}, err\n\t}\n\tif status != http.StatusCreated {\n\t\treturn InstallationToken{}, fmt.Errorf(\"githubapp: mint token: HTTP %d: %s\", status, snippet(raw))\n\t}\n\tvar out InstallationToken\n\tif err := json.Unmarshal(raw, &out); err != nil {\n\t\treturn InstallationToken{}, fmt.Errorf(\"githubapp: decode token response: %w\", err)\n\t}\n\tif out.Token == \"\" {\n\t\treturn InstallationToken{}, fmt.Errorf(\"githubapp: token response carried no token\")\n\t}\n\treturn out, nil\n}\n\n// RevokeToken DELETEs /installation/token authenticated with the token itself —\n// the job-end \"drop all agency\" step. A best-effort revoke; the ~1h natural\n// expiry is the backstop.\nfunc (a *App) RevokeToken(ctx context.Context, token string) error {\n\tstatus, raw, err := a.do(ctx, \"Bearer \"+token, http.MethodDelete, \"/installation/token\", nil)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/shared/platform/githubapp/githubapp.go#L199-L235","documentation":"Fires in MintInstallationToken() when GitHub returns a non-201 from POST /app/installations/{id}/access_tokens — the App JWT was rejected, the installation was uninstalled, or the repo is not accessible to the installation. Includes status and body snippet.","triggerScenarios":"Thrown at shared/platform/githubapp/githubapp.go:217 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the installation still exists and includes the requested repository (404/422)","Refresh the App JWT and retry on transient 5xx; check App permission settings on GitHub"],"exampleFix":null,"handlingStrategy":"retry","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"}