{"record":{"id":"0106718e086c35ef","repo":"wtfutil/wtf","slug":"s-010671","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/healthchecks/widget.go","lineNumber":175,"sourceCode":"\t// See: https://healthchecks.io/docs/api/#list-checks\n\tu, err := makeURL(widget.settings.apiURL, \"/api/v1/checks/\", widget.settings.tags)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq, err := http.NewRequest(\"GET\", u, http.NoBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"User-Agent\", userAgent)\n\treq.Header.Set(\"X-Api-Key\", widget.settings.apiKey)\n\tresp, err := http.DefaultClient.Do(req)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"%s\", resp.Status)\n\t}\n\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tvar health Health\n\terr = utils.ParseJSON(&health, resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn health.Checks, nil\n}\n","sourceCodeStart":157,"sourceCodeEnd":188,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/healthchecks/widget.go#L157-L188","documentation":"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.","triggerScenarios":"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.","commonSituations":"Expired or wrong HEALTHCHECKS_API_KEY, missing ping/API key in config, Healthchecks.io maintenance or rate limiting, corporate proxy returning 403/502.","solutions":["Verify the API key configured for the widget is valid and has access to the checks","Retry with backoff if the status is 429 or 5xx","Check network/proxy path to healthchecks.io","Confirm healthchecks.io service status"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before calling Refresh, validate the API key is set\nif os.Getenv(\"HEALTHCHECKS_API_KEY\") == \"\" {\n    log.Fatal(\"HEALTHCHECKS_API_KEY not configured\")\n}","typeGuard":null,"tryCatchPattern":"checks, err := widget.Refresh(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"401\") {\n        log.Printf(\"healthchecks auth failed, fix API key: %v\", err)\n    }\n    return // degrade gracefully, retry next tick\n}","preventionTips":["Keep the Healthchecks.io API key in env/config and rotate before expiry","Avoid aggressive Refresh intervals that trigger 429","Accept any 2xx if you control the client (status != 200 is strict)","Alert on repeated non-200 responses to catch outages early"],"tags":["http","network","go","api"],"backgroundTag":"http-non-2xx-status","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}