wtfutil/wtf · error
%s
Error message
%s
What it means
Buildkite's recentBuilds returns the raw HTTP status line (resp.Status, e.g. '401 Unauthorized') as the error whenever the Buildkite API responds outside 2xx. It is a pass-through of the API's status, so the message text is exactly what the server returned.
Source
Thrown at modules/buildkite/client.go:63
req, err := http.NewRequest("GET", url, http.NoBody)
if err != nil {
return nil, err
}
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", widget.settings.apiKey))
httpClient := &http.Client{Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
}}
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, fmt.Errorf("%s", resp.Status)
}
builds := []Build{}
err = utils.ParseJSON(&builds, resp.Body)
if err != nil {
return nil, err
}
return builds, nil
}
func branchesQuery(branches []string) string {
if len(branches) == 0 {
return ""
}
if len(branches) == 1 {
return fmt.Sprintf("?branch=%s", branches[0])View on GitHub (pinned to bb838c1ccb)
Solutions
- Read the status in the error message and fix the matching cause (401 → token, 404 → slug)
- Set/refresh the Buildkite API token with read access to the org and pipelines
- Verify organization and pipeline slugs in the widget configuration
- Retry with backoff on 429/5xx; check the Buildkite status page
Example fix
// before
req.Header.Set("Authorization", "Bearer " + os.Getenv("BUILDKITE_TOKEN")) // unset → 401 Unauthorized
// after
tok := os.Getenv("BUILDKITE_TOKEN")
if tok == "" {
return nil, errors.New("BUILDKITE_TOKEN is not set")
}
req.Header.Set("Authorization", "Bearer " + tok) Defensive patterns
Strategy: try-catch
Validate before calling
if os.Getenv("BUILDKITE_TOKEN") == "" {
return errors.New("BUILDKITE_TOKEN must be set")
} Try / catch
builds, err := client.recentBuilds()
if err != nil {
if strings.Contains(err.Error(), "429") || strings.Contains(err.Error(), "50") {
// transient: retry with backoff
} else if strings.Contains(err.Error(), "401") {
// fix API token
}
return nil, err
} Prevention
- Check token validity and org/pipeline slugs before deploying config
- Implement backoff on 429/5xx statuses
- Monitor the Buildkite status page for outages
When it happens
Trigger: Any Buildkite REST call in recentBuilds that returns status <200 or >299 — 401 (bad/missing API token), 404 (unknown slug/org), 422 (bad query params), 429/5xx from rate limits or outages.
Common situations: Expired or revoked BUILDKITE_TOKEN; wrong organization/pipeline slug in settings; hitting Buildkite rate limits; intermittent Buildkite 5xx incidents.
Related errors
- errors.New(msg.Msg)
- errors.New(hibpErr.Message)
- %s
- unexpected status %d from DEV.to API
- unexpected status code %d from football API
AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03).
Data as JSON: /api/errors/2f4b1eceb92af47c.
Report an issue: GitHub.