JuliusBrussee/caveman · error
githubapp: repository proof size mismatch
Error message
githubapp: repository proof size mismatch
What it means
After successfully base64-decoding the file content, GetFileContent cross-checks the decoded byte length against the Size field GitHub reported and enforces the library's hard 64 KiB ceiling for connection-proof files. This error means the decoded length exceeded 64 KiB or disagreed with the payload's declared size, indicating a truncated, tampered, or oversized response.
Solutions
- Check the actual file size at the requested path/ref; use a file under 64 KiB or a dedicated small proof file.
- Compare payload.Size with the real Git blob size via the Git Data API to detect truncation or proxy tampering.
- If you legitimately need larger files, bypass GetFileContent and use DoToken with a raw-archive or blob endpoint plus your own size handling.
- Fix test stubs so Size matches len(decoded) of the encoded content.
Example fix
// before // proof path points at a 1 MiB build log err := app.GetFileContent(ctx, tok, org, repo, "logs/build.log", "") // after // use the small dedicated proof file the connection control expects content, err := app.GetFileContent(ctx, tok, org, repo, ".caveman/proof.txt", "")
Defensive patterns
Strategy: validation
Validate before calling
info, _, err := app.DoToken(ctx, tok, "GET", "/repos/"+o+"/"+r+"/contents/"+p, nil)
if err != nil { return err }
// inspect Size from the raw JSON before calling GetFileContent
var meta struct{ Size int64 `json:"size"` }
_ = json.Unmarshal(raw, &meta)
if meta.Size > 64<<10 { return fmt.Errorf("file too large for proof: %d", meta.Size) } Try / catch
content, err := app.GetFileContent(ctx, tok, o, r, p, ref)
if err != nil && strings.Contains(err.Error(), "size mismatch") {
// fall back to Git blob API or reject the file
} Prevention
- Use a dedicated small proof file (<64 KiB), never arbitrary user-chosen paths.
- Verify blob size via the Git Data API when paths are dynamic.
- Keep Size fields in test stubs consistent with encoded content.
When it happens
Trigger: Calling GetFileContent on a file whose decoded bytes are larger than 64<<10, or where io truncation/proxy rewriting caused len(decoded) != payload.Size (e.g. the JSON body was cut off or the Size field was fabricated by a stub).
Common situations: Pointing the proof path at a large file (log, binary, bundled asset) instead of a tiny text proof file; a caching proxy returning a stale body with mismatched metadata; test doubles hand-crafting Size values that don't match the encoded content.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- cave_memory_too_large
- githubapp: content path is required
- githubapp: repository proof has invalid type, encoding, or…
- invalid_plan
- invalid_plan
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/25d49a03c5278ea0.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/githubapp/githubapp.go:335
}
var payload struct {
Type string `json:"type"`
Encoding string `json:"encoding"`
Content string `json:"content"`
Size int64 `json:"size"`
}
if err := json.Unmarshal(raw, &payload); err != nil {
return nil, fmt.Errorf("githubapp: decode repository proof: %w", err)
}
if payload.Type != "file" || payload.Encoding != "base64" || payload.Size < 0 || payload.Size > 64<<10 {
return nil, fmt.Errorf("githubapp: repository proof has invalid type, encoding, or size")
}
decoded, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(payload.Content, "\n", ""))
if err != nil {
return nil, fmt.Errorf("githubapp: decode repository proof content: %w", err)
}
if len(decoded) > 64<<10 || int64(len(decoded)) != payload.Size {
return nil, fmt.Errorf("githubapp: repository proof size mismatch")
}
return decoded, nil
}
// DoToken issues an authenticated GitHub REST call with an installation token and
// returns the status + raw body for the caller to parse. It is the reusable
// primitive the worker's PR opener builds the Git Data API flow on, so every
// GitHub egress goes through the one SSRF-guarded client + fixed base host.
func (a *App) DoToken(ctx context.Context, token, method, path string, body any) (int, []byte, error) {
return a.do(ctx, "Bearer "+token, method, path, body)
}
func (a *App) do(ctx context.Context, authorization, method, path string, body any) (int, []byte, error) {
if !strings.HasPrefix(path, "/") || strings.HasPrefix(path, "//") || strings.Contains(path, "\\") {
return 0, nil, fmt.Errorf("githubapp: request path must be a single-host absolute path")
}
base, err := url.Parse(a.baseURL)
if err != nil || base.Scheme == "" || base.Host == "" || base.User != nil {View on GitHub (pinned to 3ee70a1026)