JuliusBrussee/caveman · error
githubapp: installation id must be positive
Error message
githubapp: installation id must be positive
What it means
GetInstallation validates the installation ID before doing any I/O. A GitHub App installation ID is an int64 that GitHub always assigns as a positive number, so a non-positive value can never be valid. The library fails closed with this error instead of making a doomed network call.
Solutions
- Check where the installation ID originates and ensure it is parsed/loaded before the call; log it just before GetInstallation
- If it comes from an env var or config, fail fast at startup when it is missing or <= 0
- Fix parsing code to propagate the strconv error instead of defaulting to 0
- Confirm you are using the installation ID (from /app/installations or the webhook payload), not the App ID
Example fix
// before
id := cfg.InstallationID // zero value
inst, err := app.GetInstallation(ctx, id)
// after
if cfg.InstallationID <= 0 {
return fmt.Errorf("installation id not configured")
}
inst, err := app.GetInstallation(ctx, cfg.InstallationID) Defensive patterns
Strategy: validation
Validate before calling
if installationID <= 0 {
return fmt.Errorf("installation id must be configured and positive, got %d", installationID)
} Type guard
func validInstallationID(id int64) bool { return id > 0 } Try / catch
inst, err := app.GetInstallation(ctx, id)
if err != nil {
if strings.Contains(err.Error(), "installation id must be positive") {
// fix config/lookup before retrying
}
return err
} Prevention
- Validate the installation ID at config load/startup time
- Propagate strconv.ParseInt errors instead of defaulting to 0
- Distinguish App ID vs installation ID in your config naming
When it happens
Trigger: Calling App.GetInstallation(ctx, id) with id <= 0, e.g. an unset/zero-valued int64 from config, a failed strconv.ParseInt that fell back to 0, or a record where the installation ID was never populated.
Common situations: Config struct fields defaulting to 0 when the GitHub App ID env var is missing; database rows with a NULL/0 installation_id; confusion between the GitHub App ID and the installation ID; parsing "0" from CI variables.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ciphertext too short
- githubapp: app id is required
- githubapp: base_url rejected by SSRF guard
- githubapp: exactly one repository is required
- githubapp: sign app jwt
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/aca48e6215e8fe32.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/githubapp/githubapp.go:160
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
}
// Installation is the App-authenticated identity GitHub assigns to an install.
// Callers use it to reject callback-supplied ids that do not belong to this App.
type Installation struct {
ID int64 `json:"id"`
Account struct {
Login string `json:"login"`
ID int64 `json:"id"`
} `json:"account"`
}
// GetInstallation verifies an installation id against GitHub using the App JWT.
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")View on GitHub (pinned to 3ee70a1026)