{"record":{"id":"48295ffee77cc045","repo":"JuliusBrussee/caveman","slug":"githubapp-decode-repo-w","errorCode":null,"errorMessage":"githubapp: decode repo: %w","messagePattern":"githubapp: decode repo: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":265,"sourceCode":"\tFullName      string `json:\"full_name\"`\n\tDefaultBranch string `json:\"default_branch\"`\n}\n\n// GetRepo verifies that the installation token can see owner/name and returns the\n// repo's stable node id + default branch. Used by select-repo to confirm the repo\n// truly belongs to the installation before the binding goes 'active'.\nfunc (a *App) GetRepo(ctx context.Context, token, owner, name string) (Repo, error) {\n\tstatus, raw, err := a.do(ctx, \"Bearer \"+token, http.MethodGet,\n\t\t\"/repos/\"+url.PathEscape(owner)+\"/\"+url.PathEscape(name), nil)\n\tif err != nil {\n\t\treturn Repo{}, err\n\t}\n\tif status != http.StatusOK {\n\t\treturn Repo{}, fmt.Errorf(\"githubapp: get repo %s/%s: HTTP %d: %s\", owner, name, status, snippet(raw))\n\t}\n\tvar r Repo\n\tif err := json.Unmarshal(raw, &r); err != nil {\n\t\treturn Repo{}, fmt.Errorf(\"githubapp: decode repo: %w\", err)\n\t}\n\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}","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/githubapp/githubapp.go#L247-L283","documentation":"GetRepo received HTTP 200 but the response body could not be parsed as JSON into the Repo struct. The underlying json.Unmarshal error is wrapped with %w so it can be inspected with errors.As/errors.Is.","triggerScenarios":"GitHub returns a 200 whose body is not the expected repo JSON schema — e.g. a proxy/HTML error page with status 200, or a response shaped differently than expected.","commonSituations":"Corporate proxy or API gateway returning HTML with 200; GitHub API preview/behavior change; response truncated mid-stream.","solutions":["Log the raw body (snippet) at debug level to see what was actually returned","Use errors.As to unwrap and inspect the *json.UnmarshalTypeError / *json.SyntaxError","Check for transparent proxies injecting HTML; call the GitHub API endpoint directly to compare","Pin/inspect the Go type expectations in shared/platform/githubapp/githubapp.go against current GitHub API docs"],"exampleFix":"// before\nif err := json.Unmarshal(raw, &r); err != nil { ... }\n// after (caller-side unwrap)\nvar syn *json.SyntaxError\nif errors.As(err, &syn) {\n    log.Printf(\"invalid JSON at offset %d\", syn.Offset)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"var syn *json.SyntaxError\nif errors.As(err, &syn) {\n    log.Printf(\"repo response not JSON at offset %d — check proxy\", syn.Offset)\n} else if var te *json.UnmarshalTypeError; errors.As(err, &te) {\n    log.Printf(\"repo response shape changed at %s\", te.Field)\n}","preventionTips":["Ensure no transparent proxy rewrites api.github.com traffic","Pin expectations to the documented GitHub repo JSON schema","Log raw bodies at debug level for decoding failures","Keep the Repo struct in sync with GitHub API changes"],"tags":["github","json","decoding"],"backgroundTag":"json-unmarshal-failed","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"}