{"record":{"id":"c0752e418764f114","repo":"theonedev/onedev","slug":"http-request-failed-status-s","errorCode":null,"errorMessage":"Http request failed (status: %s)","messagePattern":"Http request failed \\(status: (.+?)\\)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/JerseyUtils.java","lineNumber":44,"sourceCode":"\t\t\t\treturn String.format(\"Http request failed (url: %s, status code: %d)\", url, status);\n\t\t\t}\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tpublic static JsonNode get(Client client, String apiEndpoint, TaskLogger logger) {\n\t\tWebTarget target = client.target(apiEndpoint);\n\t\tInvocation.Builder builder =  target.request();\n\t\ttry (Response response = builder.get()) {\n\t\t\tint status = response.getStatus();\n\t\t\tif (status != 200) {\n\t\t\t\tString errorMessage = response.readEntity(String.class);\n\t\t\t\tif (StringUtils.isNotBlank(errorMessage)) {\n\t\t\t\t\tthrow new ExplicitException(String.format(\"Http request failed (url: %s, status code: %d, error message: %s)\", \n\t\t\t\t\t\t\tapiEndpoint, status, errorMessage));\n\t\t\t\t} else {\n\t\t\t\t\tthrow new ExplicitException(String.format(\"Http request failed (status: %s)\", status));\n\t\t\t\t}\n\t\t\t} \n\t\t\treturn response.readEntity(JsonNode.class);\n\t\t}\n\t}\n\t\n\tpublic static interface PageDataConsumer {\n\t\t\n\t\tvoid consume(List<JsonNode> pageData) throws InterruptedException;\n\t\t\n\t}\n\t\n}\n","sourceCodeStart":26,"sourceCodeEnd":58,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/JerseyUtils.java#L26-L58","documentation":"JerseyUtils.get throws ExplicitException(\"Http request failed (status: <status>)\") when a GET returns a non-200 status but the response has no readable error message entity. The status code alone is reported because the server supplied no body.","triggerScenarios":"Calling JerseyUtils.get(apiEndpoint) and receiving 401/403/404/429/5xx with an empty body — commonly when a proxy/gateway strips error bodies or the server returns bare status codes.","commonSituations":"Reverse proxies (nginx 502/503 without body), authentication failures that return empty 401s, gateway timeouts, or firewalls blocking with bare responses.","solutions":["Check the status code in the message: 401/403 -> fix credentials/permissions; 404 -> verify URL; 429 -> back off and retry; 5xx -> server-side problem.","Inspect proxy/gateway logs (nginx, load balancer) since empty bodies usually mean the intermediary produced the status.","Reproduce with curl -i on the same endpoint to see raw response and headers.","Confirm network/firewall rules allow the outbound request from the server host."],"exampleFix":"// before (token revoked, empty 401 body)\nJsonNode node = JerseyUtils.get(\"https://host/api/project\"); // 'Http request failed (status: 401)'\n// after: refresh/reissue token before calling\nString freshToken = refreshToken();\n// rebuild client with freshToken, then\nJsonNode node = JerseyUtils.get(\"https://host/api/project\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    JsonNode node = JerseyUtils.get(apiEndpoint);\n} catch (ExplicitException e) {\n    Matcher m = Pattern.compile(\"status: (\\\\d+)\").matcher(e.getMessage());\n    if (m.find()) {\n        int status = Integer.parseInt(m.group(1));\n        // 401/403: fix auth; 404: fix url; 429/5xx: retry with backoff\n    }\n}","preventionTips":["Inspect the status code first and map it to auth/URL/server diagnosis.","Check reverse proxy and gateway logs when bodies are empty.","Reproduce with curl -i to see full raw response headers.","Confirm outbound network/firewall access from the server host."],"tags":["http","rest","jersey","api"],"backgroundTag":"http-non-200-response","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}