mislav/hub · error
Error %s: %s (HTTP %d)
Error message
Error %s: %s (HTTP %d)
What it means
Also from checkStatus, this variant fires when the HTTP request completed but with an unexpected status code AND the response body could not be parsed into a structured error (response.ErrorInfo() failed). The library then reports the raw error text plus the HTTP status code, e.g. 'Error creating pull request: ... (HTTP 502)'.
Source
Thrown at github/client.go:1206
return GitHubHost
case "api.github.localhost":
return "github.localhost"
default:
return host
}
}
func checkStatus(expectedStatus int, action string, response *simpleResponse, err error) error {
if err != nil {
errStr := err.Error()
if urlErr, isURLErr := err.(*url.Error); isURLErr {
errStr = fmt.Sprintf("%s %s: %s", urlErr.Op, urlErr.URL, urlErr.Err)
}
return fmt.Errorf("Error %s: %s", action, errStr)
} else if response.StatusCode != expectedStatus {
errInfo, err := response.ErrorInfo()
if err != nil {
return fmt.Errorf("Error %s: %s (HTTP %d)", action, err.Error(), response.StatusCode)
}
return FormatError(action, errInfo)
}
return nil
}
// FormatError annotates an HTTP response error with user-friendly messages
func FormatError(action string, err error) error {
if e, ok := err.(*errorInfo); ok {
return formatError(action, e)
}
return err
}
func formatError(action string, e *errorInfo) error {
var reason string
if s := strings.SplitN(e.Response.Status, " ", 2); len(s) >= 2 {
reason = strings.TrimSpace(s[1])View on GitHub (pinned to 5c547ed804)
Solutions
- Note the HTTP code in the message: retry on 5xx after a short delay (usually transient).
- Inspect the raw response (curl the same endpoint) to see the non-JSON body.
- If a proxy is intercepting, bypass it or fix its configuration for api.github.com.
- Check the GitHub status page for ongoing incidents.
Defensive patterns
Strategy: retry
Type guard
func isUnexpectedStatus(err error) bool {
return strings.Contains(err.Error(), "(HTTP ")
} Try / catch
if m := httpStatusRe.FindStringSubmatch(err.Error()); m != nil {
code, _ := strconv.Atoi(m[1])
if code >= 500 { backoffAndRetry() }
} Prevention
- Retry 5xx responses with backoff — they are usually transient.
- Bypass or fix HTML-returning proxies for api.github.com.
- Watch the GitHub status page; fail fast during incidents.
- On enterprise instances, verify the appliance health before API calls.
When it happens
Trigger: Server returned a status != expectedStatus with a body that isn't the expected JSON error format: HTML error pages from proxies/load balancers, 502/503/504 from GitHub, or empty bodies on 4xx/5xx.
Common situations: GitHub incident causing 5xx responses; a corporate proxy returning an HTML block page; hitting a misconfigured enterprise GitHub instance returning non-JSON errors; rate-limit pages served as HTML.
Related errors
- Error creating fork: %s already exists on %s
- Error: that fork is not available anymore
- %s\nAre you sure that %s exists?
- Unable to find release with tag name `%s'
- API error: %s
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/84c83511e79b52e7.
Report an issue: GitHub.