JuliusBrussee/caveman · error
githubapp: decode repository proof content
Error message
githubapp: decode repository proof content: %w
What it means
GetFileContent fetches a repository file (used for connection proofs) from GitHub's contents API, which returns the content base64-encoded. After stripping newlines GitHub inserts into the base64 blob, the library decodes it with Go's strict StdEncoding. This error wraps any base64 decode failure, meaning the API payload's content field was not valid standard base64.
Solutions
- Print the wrapped base64.CorruptInputError offset from the %w chain to find the first illegal byte in the content string.
- Verify the request hit the real GitHub API (check baseURL configuration) and that the path targets a regular file, not a symlink/submodule entry.
- If a proxy or test fixture is involved, regenerate the fixture with proper standard base64 (e.g. base64.StdEncoding.EncodeToString) including correct padding.
- If content may be URL-safe base64, decode defensively: try base64.StdEncoding then base64.RawURLEncoding before failing.
Example fix
// before
content := "aGVsbG8_g" // URL-safe char '_' illegal for StdEncoding
decoded, err := base64.StdEncoding.DecodeString(content)
// after
content = strings.ReplaceAll(content, "\n", "")
decoded, err := base64.StdEncoding.DecodeString(content)
if err != nil {
decoded, err = base64.RawURLEncoding.DecodeString(content)
} Defensive patterns
Strategy: validation
Validate before calling
payload, err := fetchPayload(ctx)
if err != nil { return err }
trimmed := strings.ReplaceAll(payload.Content, "\n", "")
if _, err := base64.StdEncoding.DecodeString(trimmed); err != nil {
return fmt.Errorf("content is not valid std base64: %w", err)
} Try / catch
if _, err := app.GetFileContent(ctx, tok, o, r, p, ref); err != nil {
var corrupt base64.CorruptInputError
if errors.As(err, &corrupt) {
// handle invalid encoding: re-fetch or log payload shape
}
} Prevention
- Always fetch files via the real GitHub API, never hand-written fixtures without round-tripping through base64.StdEncoding.
- Target regular files, not symlinks or submodules.
- Round-trip test fixtures with Encode/Decode to guarantee validity.
When it happens
Trigger: Calling GetFileContent when the GitHub contents endpoint returns a payload whose Content field fails strict std base64 decoding — e.g. the endpoint returned a JSON error/alternate shape that still passed the type/encoding checks, a proxy mangled the content string, or the response contains URL-safe base64 characters (- and _) instead of standard (+ and /).
Common situations: Hitting a GitHub Enterprise Server or proxy that returns a non-canonical encoding; a test stub or recorded fixture with hand-written base64 containing illegal characters or wrong padding; the path pointed at an object whose API response shape differs (e.g. symlinks or submodule metadata variants) while type/encoding fields coincidentally matched.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- githubapp: decode repo installation
- githubapp: decode repo
- githubapp: decode repository proof
- cave artifact response missing artifact_id
- cave artifact response missing artifact_id
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/b27777588ce17a1d.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/githubapp/githubapp.go:332
}
if status != http.StatusOK {
return nil, fmt.Errorf("githubapp: get repository proof: HTTP %d: %s", status, snippet(raw))
}
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")View on GitHub (pinned to 3ee70a1026)