{"record":{"id":"611d2f2467db1a5d","repo":"wtfutil/wtf","slug":"s-611d2f","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/hackernews/client.go","lineNumber":70,"sourceCode":"\tapiEndpoint = \"https://hacker-news.firebaseio.com/v0/\"\n)\n\nfunc apiRequest(path string) ([]byte, error) {\n\treq, err := http.NewRequest(\"GET\", apiEndpoint+path+\".json\", http.NoBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thttpClient := &http.Client{}\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\treturn nil, fmt.Errorf(\"%s\", resp.Status)\n\t}\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn body, nil\n}\n","sourceCodeStart":52,"sourceCodeEnd":79,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/hackernews/client.go#L52-L79","documentation":"apiRequest in the HackerNews module returns the raw HTTP status line (e.g. '503 Service Unavailable') as the error whenever the API responds with a status outside 200-299. It is a generic transport-level failure guard: the request completed, but the server rejected it. The body is discarded, so the real reason (if any) is only in the status code.","triggerScenarios":"Any GetMessages or GetRoom call where the HN/Firebase-backed endpoint returns a 4xx/5xx status: rate limiting (429), server errors (5xx), wrong/redirected URL, or a proxy returning 404/403.","commonSituations":"HackerNews/Firebase API outage or throttling under heavy polling, corporate proxy intercepting requests, misconfigured base URL pointing to a wrong host, or transient DNS/network failures surfacing as gateway 502/504.","solutions":["Check the error message for the status code and retry with backoff for 429/5xx","Verify the client's base URL / endpoint configuration is correct","Check network connectivity and any proxy settings","Confirm the upstream service status before further debugging"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"msgs, err := widget.GetMessages(room)\nif err != nil {\n    log.Printf(\"HN api error (check status in msg): %v\", err)\n    return // keep last known data, retry later\n}","preventionTips":["Poll at reasonable intervals to avoid 429 rate limiting","Pin/verify the client's base URL after upstream changes","Run behind a retry wrapper with backoff for 5xx","Monitor upstream service status pages"],"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"}