{"record":{"id":"8e298dd24975fa36","repo":"JuliusBrussee/caveman","slug":"githubapp-get-repository-proof-http-d-s","errorCode":null,"errorMessage":"githubapp: get repository proof: HTTP %d: %s","messagePattern":"githubapp: get repository proof: HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":316,"sourceCode":"// 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()\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 {","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/githubapp/githubapp.go#L298-L334","documentation":"GetFileContent requested the contents endpoint (GET /repos/{owner}/{name}/contents/{path}) with an installation token and received a non-200 status. The error carries the status code and a body snippet.","triggerScenarios":"Non-200 from the contents endpoint: 404 when the file or repo is not visible to the installation, 401 for an expired token, 403 rate limit or file >1MB via contents API, 422 when ref is invalid.","commonSituations":"Requesting a file the App installation cannot see; file larger than the contents-API limit; wrong branch/tag passed as ref; token expired mid-workflow.","solutions":["Check status: 404 → verify the file path, ref, and that the installation has access to the repo","Refresh the installation token on 401; regenerate before long operations","On 403 inspect X-RateLimit headers or use the Git blobs API for large files","Fix the ref parameter to an existing branch, tag, or commit SHA (422)"],"exampleFix":"// before\nb, err := app.GetFileContent(ctx, tok, owner, name, path, ref)\nif err != nil { return err }\n// after\nb, err := app.GetFileContent(ctx, tok, owner, name, path, ref)\nif err != nil {\n    if strings.Contains(err.Error(), \"HTTP 404\") {\n        return fmt.Errorf(\"proof file %s@%s not found or not accessible: %w\", path, ref, err)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// pre-check reachability of the file via the repo tree, and keep files <64KiB\nif owner == \"\" || name == \"\" || path == \"\" { return errors.New(\"owner, name and path are required\") }","typeGuard":"func isNotFound(err error) bool { return err != nil && strings.Contains(err.Error(), \"HTTP 404\") }\nfunc isRateLimited(err error) bool { return err != nil && strings.Contains(err.Error(), \"HTTP 403\") }","tryCatchPattern":"var content []byte\nvar err error\nfor i := 0; i < 3; i++ {\n    content, err = app.GetFileContent(ctx, tok, owner, name, path, ref)\n    if err == nil || isNotFound(err) { break } // don't retry genuine 404s\n    time.Sleep(time.Duration(1<<i) * time.Second) // back off on 403/5xx\n}","preventionTips":["Refresh installation tokens before long proof flows","Verify ref (branch/tag/SHA) exists before fetching","Remember the contents API rejects files >1MB — use the blobs API for big files","Grant the installation access to every repo you will read"],"tags":["github","http","file-content"],"backgroundTag":"http-error-response","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"}