{"record":{"id":"fe0b189e9f727d49","repo":"JuliusBrussee/caveman","slug":"githubapp-repository-proof-has-invalid-type-enco","errorCode":null,"errorMessage":"githubapp: repository proof has invalid type, encoding, or size","messagePattern":"githubapp: repository proof has invalid type, encoding, or size","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":328,"sourceCode":"\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.\nfunc (a *App) DoToken(ctx context.Context, token, method, path string, body any) (int, []byte, error) {\n\treturn a.do(ctx, \"Bearer \"+token, method, path, body)\n}","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/githubapp/githubapp.go#L310-L346","documentation":"The decoded contents payload passed JSON decoding but failed structural validation: the type must be \"file\", encoding must be \"base64\", and size must be within [0, 64 KiB]. Anything else is rejected because connection-proof files are expected to be tiny text files.","triggerScenarios":"Payload where type != \"file\" (e.g. a directory/symlink entry), encoding != \"base64\" (GitHub can return \"none\" for empty files), negative size, or size > 65536 bytes.","commonSituations":"Pointing the proof path at a directory instead of a file; empty files return encoding \"none\" in GitHub's contents API; proof file grown beyond 64 KiB; symlink entries.","solutions":["Ensure the configured path points to a regular text file, not a directory or symlink","Check the file size in the repo — keep the proof file under 64 KiB","Handle empty files explicitly: GitHub returns encoding \"none\" and empty content for 0-byte files","Verify the ref resolves to a commit where the file is the expected type"],"exampleFix":"// before\nproofPath = cfg.ProofPath            // may be a directory or oversize file\n// after\n// ensure repo contains docs/proof.txt as a plain <64KiB text file\ninfo, _ := gh.GetRepo(ctx, tok, owner, name)\n_ = info\nproofPath = \"docs/proof.txt\"","handlingStrategy":"validation","validationCode":"// before calling, ensure the configured proof path is a small regular text file\n// (checked via the repo tree or at authoring time)\nif fileInfo, err := os.Stat(localProofPath); err != nil || fileInfo.Size() > 64<<10 {\n    return errors.New(\"proof file must be a text file under 64KiB\")\n}","typeGuard":null,"tryCatchPattern":"content, err := app.GetFileContent(ctx, tok, owner, name, path, ref)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid type, encoding, or size\") {\n        return fmt.Errorf(\"%s must be a plain <64KiB text file (not dir/symlink/empty)\", path)\n    }\n    return err\n}","preventionTips":["Keep proof files as plain text well under 64 KiB","Never point the proof path at a directory or symlink","Handle GitHub's encoding:\"none\" for zero-byte files explicitly","Pin the ref to a commit where the file has the expected shape"],"tags":["github","validation","payload"],"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"}