JuliusBrussee/caveman · error

githubapp: repository proof has invalid type, encoding, or…

Error message

githubapp: repository proof has invalid type, encoding, or size

What it means

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.

Solutions

  1. Ensure the configured path points to a regular text file, not a directory or symlink
  2. Check the file size in the repo — keep the proof file under 64 KiB
  3. Handle empty files explicitly: GitHub returns encoding "none" and empty content for 0-byte files
  4. Verify the ref resolves to a commit where the file is the expected type

Example fix

// before
proofPath = cfg.ProofPath            // may be a directory or oversize file
// after
// ensure repo contains docs/proof.txt as a plain <64KiB text file
info, _ := gh.GetRepo(ctx, tok, owner, name)
_ = info
proofPath = "docs/proof.txt"
Defensive patterns

Strategy: validation

Validate before calling

// before calling, ensure the configured proof path is a small regular text file
// (checked via the repo tree or at authoring time)
if fileInfo, err := os.Stat(localProofPath); err != nil || fileInfo.Size() > 64<<10 {
    return errors.New("proof file must be a text file under 64KiB")
}

Try / catch

content, err := app.GetFileContent(ctx, tok, owner, name, path, ref)
if err != nil {
    if strings.Contains(err.Error(), "invalid type, encoding, or size") {
        return fmt.Errorf("%s must be a plain <64KiB text file (not dir/symlink/empty)", path)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/fe0b189e9f727d49. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/githubapp/githubapp.go:328

	}
	status, raw, err := a.do(ctx, "Bearer "+token, http.MethodGet, endpoint, nil)
	if err != nil {
		return nil, err
	}
	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)
}

View on GitHub (pinned to 3ee70a1026)