JuliusBrussee/caveman · error

githubapp: decode installation: %w

Error message

githubapp: decode installation: %w

What it means

Decode wrap in GetInstallation: the 200 response body from /app/installations/{id} is not valid JSON for the Installation shape. The GitHub response is the faulty input; treat as API drift or interception.

Source

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

func (a *App) GetInstallation(ctx context.Context, installationID int64) (Installation, error) {
	var out Installation
	if installationID <= 0 {
		return out, fmt.Errorf("githubapp: installation id must be positive")
	}
	jwt, err := a.AppJWT()
	if err != nil {
		return out, err
	}
	status, raw, err := a.do(ctx, "Bearer "+jwt, http.MethodGet,
		"/app/installations/"+strconv.FormatInt(installationID, 10), nil)
	if err != nil {
		return out, err
	}
	if status != http.StatusOK {
		return out, fmt.Errorf("githubapp: get installation: HTTP %d: %s", status, snippet(raw))
	}
	if err := json.Unmarshal(raw, &out); err != nil {
		return out, fmt.Errorf("githubapp: decode installation: %w", err)
	}
	if out.ID != installationID || out.Account.ID <= 0 || strings.TrimSpace(out.Account.Login) == "" {
		return Installation{}, fmt.Errorf("githubapp: installation response identity mismatch")
	}
	return out, nil
}

// MintInstallationToken POSTs /app/installations/{id}/access_tokens narrowed to
// `repos` and `perms`, returning a ~1h token. Defaults (perms nil) are
// contents:write + pull_requests:write — enough to push a branch and open a draft
// PR, never to merge.
func (a *App) MintInstallationToken(ctx context.Context, installationID int64, repos []string, perms map[string]string) (InstallationToken, error) {
	if installationID <= 0 {
		return InstallationToken{}, fmt.Errorf("githubapp: installation id must be positive")
	}
	if len(repos) != 1 || strings.TrimSpace(repos[0]) == "" {
		return InstallationToken{}, fmt.Errorf("githubapp: exactly one repository is required")
	}

View on GitHub (pinned to 766dce6b13)

Solutions

  1. Retry the request; if persistent, inspect the raw body (kept in the HTTP error snippet) for API schema changes
  2. Verify the API version header and endpoint are current
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at shared/platform/githubapp/githubapp.go:175 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/6e4169981cadaecb. Report an issue: GitHub.