{"record":{"id":"6b7bd21b3b338ed8","repo":"JuliusBrussee/caveman","slug":"githubapp-decode-repository-proof-w","errorCode":null,"errorMessage":"githubapp: decode repository proof: %w","messagePattern":"githubapp: decode repository proof: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":325,"sourceCode":"\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()\n\t}\n\tstatus, raw, err := a.do(ctx, \"Bearer \"+token, http.MethodGet, endpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif status != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"githubapp: get repository proof: HTTP %d: %s\", status, snippet(raw))\n\t}\n\tvar payload struct {\n\t\tType     string `json:\"type\"`\n\t\tEncoding string `json:\"encoding\"`\n\t\tContent  string `json:\"content\"`\n\t\tSize     int64  `json:\"size\"`\n\t}\n\tif err := json.Unmarshal(raw, &payload); err != nil {\n\t\treturn nil, fmt.Errorf(\"githubapp: decode repository proof: %w\", err)\n\t}\n\tif payload.Type != \"file\" || payload.Encoding != \"base64\" || payload.Size < 0 || payload.Size > 64<<10 {\n\t\treturn nil, fmt.Errorf(\"githubapp: repository proof has invalid type, encoding, or size\")\n\t}\n\tdecoded, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(payload.Content, \"\\n\", \"\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"githubapp: decode repository proof content: %w\", err)\n\t}\n\tif len(decoded) > 64<<10 || int64(len(decoded)) != payload.Size {\n\t\treturn nil, fmt.Errorf(\"githubapp: repository proof size mismatch\")\n\t}\n\treturn decoded, nil\n}\n\n// DoToken issues an authenticated GitHub REST call with an installation token and\n// returns the status + raw body for the caller to parse. It is the reusable\n// primitive the worker's PR opener builds the Git Data API flow on, so every\n// GitHub egress goes through the one SSRF-guarded client + fixed base host.","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/shared/platform/githubapp/githubapp.go#L307-L343","documentation":"GetFileContent got a 200 from the contents endpoint but the JSON body did not decode into the type/encoding/content/size payload struct. The success response is not the documented file-content shape (e.g. a directory listing or an error page returned with 200).","triggerScenarios":"Thrown at shared/platform/githubapp/githubapp.go:325 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request; inspect the raw body if persistent for API schema drift"],"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"}