JuliusBrussee/caveman · error

githubapp: request failed

Error message

githubapp: request failed: %w

What it means

do() executed the request via the App's HTTP client and the transport itself failed — DNS resolution, TCP connect, TLS handshake, context cancellation, or a proxy error. This error wraps the underlying *url.Error; note it returns (0, nil, err), so no status code is available. Unlike HTTP 4xx/5xx, this is a transport-level failure.

Solutions

  1. Unwrap the error and check for context.DeadlineExceeded — if so, retry with a longer timeout or add retry with backoff.
  2. Verify network egress: curl -v https://api.github.com from the same host/container to isolate DNS vs TLS vs proxy.
  3. Check proxy environment variables (HTTPS_PROXY/NO_PROXY) — the default http.Transport honors them; ensure the GitHub host is reachable through the configured proxy.
  4. Confirm the baseURL host resolves (nslookup) and, for GitHub Enterprise, that the CA is trusted by the client's TLS config.

Example fix

// before
ctx := context.Background()
inst, err := app.GetInstallation(ctx, tok) // hangs then dies behind proxy
// after
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
inst, err := app.GetInstallation(ctx, tok)
if err != nil {
    var netErr net.Error
    if errors.As(err, &netErr) && netErr.Timeout() {
        // retry with backoff
    }
}
Defensive patterns

Strategy: retry

Validate before calling

// reachability probe before batch operations
req, _ := http.NewRequestWithContext(ctx, "GET", baseURL+"/zen", nil)
if _, err := http.DefaultClient.Do(req); err != nil {
    return fmt.Errorf("GitHub API unreachable: %w", err)
}

Try / catch

var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
    // retry with backoff
}
if errors.Is(err, context.DeadlineExceeded) {
    // extend deadline or abort batch
}

Prevention

When it happens

Trigger: Calling any App method (GetInstallation, MintInstallationToken, RevokeToken, GetRepo, GetRepoInstallation, GetFileContent, DoToken) when the network is unreachable, DNS for api.github.com (or the GHE host) fails, TLS is rejected, an egress proxy is down, or the ctx deadline fires mid-request.

Common situations: Corporate proxy/firewall blocking api.github.com; running in an air-gapped environment pointing at an unreachable GHE host; context timeout too aggressive; VPN disconnected; DNS misconfiguration in containers (no resolv.conf entry for the host).

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

		b, err := json.Marshal(body)
		if err != nil {
			return 0, nil, fmt.Errorf("githubapp: marshal request: %w", err)
		}
		reader = bytes.NewReader(b)
	}
	req, err := http.NewRequestWithContext(ctx, method, target.String(), reader)
	if err != nil {
		return 0, nil, fmt.Errorf("githubapp: build request: %w", err)
	}
	req.Header.Set("Authorization", authorization)
	req.Header.Set("Accept", "application/vnd.github+json")
	req.Header.Set("X-GitHub-Api-Version", "2022-11-28")
	if body != nil {
		req.Header.Set("Content-Type", "application/json")
	}
	resp, err := a.httpClient.Do(req)
	if err != nil {
		return 0, nil, fmt.Errorf("githubapp: request failed: %w", err)
	}
	defer resp.Body.Close()
	raw, err := io.ReadAll(io.LimitReader(resp.Body, 4<<20))
	if err != nil {
		return resp.StatusCode, nil, fmt.Errorf("githubapp: read response: %w", err)
	}
	return resp.StatusCode, raw, nil
}

// parseRSAPrivateKey accepts a PKCS#1 ("RSA PRIVATE KEY") or PKCS#8
// ("PRIVATE KEY") PEM — GitHub Apps download PKCS#1, but Cloud KMS / openssl
// conversions emit PKCS#8, so we accept both.
func parseRSAPrivateKey(pemBytes []byte) (*rsa.PrivateKey, error) {
	block, _ := pem.Decode(pemBytes)
	if block == nil {
		return nil, fmt.Errorf("githubapp: private key is not valid PEM")
	}
	if key, err := x509.ParsePKCS1PrivateKey(block.Bytes); err == nil {

View on GitHub (pinned to 3ee70a1026)