wtfutil/wtf · error

%s

Error message

%s

What it means

travisBuildRequest wraps Travis CI API calls and enforces a 2xx status; anything outside 200-299 is rejected with the raw resp.Status string. Callers (BuildsFor) then fail with that status text, e.g. "404 Not Found" or "403 Forbidden".

Source

Thrown at modules/travisci/client.go:74

	if err != nil {
		return nil, err
	}
	req.Header.Add("Accept", "application/json")
	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Travis-API-Version", "3")

	bearer := fmt.Sprintf("token %s", settings.apiKey)
	req.Header.Add("Authorization", bearer)

	httpClient := &http.Client{}
	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)
	}

	return resp, nil
}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Check the status string: 404 usually means org-vs-com host mismatch — verify the configured API URL
  2. Regenerate the Travis CI API token if you get 403
  3. Confirm the repository slug matches the current GitHub repo name
  4. Retry later for 429/5xx; Travis may be degraded

Example fix

// before
apiURL: "https://api.travis-ci.org/repo/my-org/my-repo/builds" // repo moved to .com
// after
apiURL: "https://api.travis-ci.com/repo/my-org/my-repo/builds"
Defensive patterns

Strategy: retry

Validate before calling

if repoSlug == "" || strings.Count(repoSlug, "%2F") == 0 && !strings.Contains(repoSlug, "/") { return errors.New("repo slug must be owner%2Fname") }

Type guard

func isAuthError(status string) bool { return strings.HasPrefix(status, "403") || strings.HasPrefix(status, "401") }

Try / catch

builds, err := t.BuildsFor()
if err != nil {
    if strings.HasPrefix(err.Error(), "404") { switchAPIHost(orgToCom) }
    else if strings.HasPrefix(err.Error(), "403") { refreshToken() }
    else { log.Printf("travis: %v", err) }
}

Prevention

When it happens

Trigger: Any Travis API endpoint returning 300+: 403 when the token is missing/expired/insufficient, 404 for wrong repo slug or wrong API host (org vs com), 429 rate limiting, 5xx Travis outages.

Common situations: Travis CI .org vs .com migration (repo lives on the other host); expired TRAVIS_TOKEN; repository renamed or transferred so the slug is stale; open-source repos moved off travis-ci.org after its shutdown.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/3c930ca4ea1ea036. Report an issue: GitHub.