{"record":{"id":"77508e3e073bc3e9","repo":"wtfutil/wtf","slug":"s-77508e","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/updown/widget.go","lineNumber":186,"sourceCode":"\t// See: https://updown.io/api#rest\n\tu, err := makeURL(apiURLBase, \"/api/checks\")\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 checks []Check\n\terr = utils.ParseJSON(&checks, resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(widget.tokenSet) > 0 {\n\t\tchecks = filterChecks(checks, widget.tokenSet)\n\t}\n\n\treturn checks, nil\n}\n","sourceCodeStart":168,"sourceCodeEnd":203,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/updown/widget.go#L168-L203","documentation":"Raised in getExistingChecks when the updown.io API returns a non-200 status: the error is only the HTTP status string (e.g. '401 Unauthorized'). Typical causes are an invalid X-API-KEY, exceeded rate limits, or updown.io service errors while listing existing checks.","triggerScenarios":"Any non-200 from updown.io /checks: 401 for invalid/missing UPDOWN_TOKEN, 404/410 for wrong API version path, 429 for rate limits, 5xx outages.","commonSituations":"Missing or revoked API token in config; token belonging to another account; updown.io API version changes; transient 5xx.","solutions":["Verify the UPDOWN token is set and valid (test with curl -H 'X-Api-Token: ...' https://updown.io/api/v1/checks)","Regenerate the token in the updown.io account settings if revoked","Retry later on 5xx/429","Confirm the widget is pointed at the current API base URL"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if apiKey == \"\" { return errors.New(\"updown API token not configured\") }\ntok := os.Getenv(\"UPDOWN_TOKEN\")\nif tok == \"\" { return errors.New(\"missing UPDOWN token\") }","typeGuard":null,"tryCatchPattern":"checks, err := w.getExistingChecks()\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"401\") { log.Printf(\"updown auth failed; check token\") }\n    else { log.Printf(\"updown: %v\", err) }\n    return\n}","preventionTips":["Store the API token in an environment variable and check it at startup","Test the token with curl against /api/v1/checks before deploying","Watch for 401 after rotating tokens in the updown dashboard","Back off on 429 rather than hammering the API"],"tags":["http","updown","network","go"],"backgroundTag":"http-non-200-response","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"}