{"record":{"id":"3c29636a105248f0","repo":"JuliusBrussee/caveman","slug":"githubapp-repo-installation-response-carried-no-i","errorCode":null,"errorMessage":"githubapp: repo installation response carried no id","messagePattern":"githubapp: repo installation response carried no id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":291,"sourceCode":"func (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}\n\tfor i := range segments {\n\t\tsegments[i] = url.PathEscape(segments[i])\n\t}\n\tendpoint := \"/repos/\" + url.PathEscape(owner) + \"/\" + url.PathEscape(name) + \"/contents/\" + strings.Join(segments, \"/\")\n\tif strings.TrimSpace(ref) != \"\" {\n\t\tendpoint += \"?\" + url.Values{\"ref\": {ref}}.Encode()","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/githubapp/githubapp.go#L273-L309","documentation":"The installation response parsed as JSON but the installation ID field was absent or non-positive (out.ID <= 0). The library treats an installation object without a valid id as unusable and rejects it defensively.","triggerScenarios":"GitHub returns an installation-shaped JSON object whose id field is missing, null, zero, or negative — e.g. an unexpected payload variant or a stub/mock server returning incomplete data.","commonSituations":"Testing against a fake/mock GitHub server that omits the id field; GitHub API schema drift where the id moved or was renamed; caching layer returning partial objects.","solutions":["Inspect the raw response body — verify the JSON actually contains a positive numeric id","Check whether a mock/test server is in play and fix its fixture to include id","Update the Installation struct mapping if GitHub renamed/moved the id field","Treat as an upstream contract violation and surface to the user — retry will not help"],"exampleFix":"// before\nif out.ID <= 0 { return Installation{}, fmt.Errorf(\"githubapp: repo installation response carried no id\") }\n// after (fixture fix in mock server)\n{\"id\": 12345, \"app_id\": 6789, ...}  // mock must include a positive id","handlingStrategy":"validation","validationCode":"// when serving stub responses, always include a positive id\n// assert on the parsed fixture before returning it\nif fixture.ID <= 0 { t.Fatal(\"fixture missing installation id\") }","typeGuard":"func hasValidInstallationID(in githubapp.Installation) bool { return in.ID > 0 }","tryCatchPattern":"inst, err := app.GetRepoInstallation(ctx, owner, name)\nif err != nil || inst.ID <= 0 {\n    return fmt.Errorf(\"could not resolve installation for %s/%s: %w\", owner, name, err)\n}","preventionTips":["Keep mock-server fixtures complete (id must be positive)","Watch for GitHub schema drift on the installation object","Treat missing id as a contract violation — do not blind-retry"],"tags":["github","installation","response-validation"],"backgroundTag":"unexpected-response-shape","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"}