wtfutil/wtf · error

%s

Error message

%s

What it means

getExistingChecks in the HealthChecks module returns the raw HTTP status line as an error when the Healthchecks.io API responds with anything other than 200. Unlike typical clients it only accepts exactly 200, so valid 2xx responses like 204 are also treated as failures. This guards the Refresh flow before parsing the checks list.

Source

Thrown at modules/healthchecks/widget.go:175

	// See: https://healthchecks.io/docs/api/#list-checks
	u, err := makeURL(widget.settings.apiURL, "/api/v1/checks/", widget.settings.tags)
	if err != nil {
		return nil, err
	}
	req, err := http.NewRequest("GET", u, http.NoBody)
	if err != nil {
		return nil, err
	}
	req.Header.Set("User-Agent", userAgent)
	req.Header.Set("X-Api-Key", widget.settings.apiKey)
	resp, err := http.DefaultClient.Do(req)

	if err != nil {
		return nil, err
	}

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("%s", resp.Status)
	}

	defer func() { _ = resp.Body.Close() }()

	var health Health
	err = utils.ParseJSON(&health, resp.Body)
	if err != nil {
		return nil, err
	}

	return health.Checks, nil
}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Verify the API key configured for the widget is valid and has access to the checks
  2. Retry with backoff if the status is 429 or 5xx
  3. Check network/proxy path to healthchecks.io
  4. Confirm healthchecks.io service status
Defensive patterns

Strategy: try-catch

Validate before calling

// before calling Refresh, validate the API key is set
if os.Getenv("HEALTHCHECKS_API_KEY") == "" {
    log.Fatal("HEALTHCHECKS_API_KEY not configured")
}

Try / catch

checks, err := widget.Refresh(ctx)
if err != nil {
    if strings.Contains(err.Error(), "401") {
        log.Printf("healthchecks auth failed, fix API key: %v", err)
    }
    return // degrade gracefully, retry next tick
}

Prevention

When it happens

Trigger: A Refresh call where the /api/v1/checks/ request returns e.g. 401 (bad API key), 403, 429 (rate limited), or 5xx from Healthchecks.io.

Common situations: Expired or wrong HEALTHCHECKS_API_KEY, missing ping/API key in config, Healthchecks.io maintenance or rate limiting, corporate proxy returning 403/502.

Related errors


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