{"record":{"id":"d8e02ce960d84d20","repo":"apache/seatunnel","slug":"request-failed-with-code","errorCode":null,"errorMessage":"Request failed with code:{}","messagePattern":"Request failed with code:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client/HttpHelper.java","lineNumber":62,"sourceCode":"import java.util.HashMap;\nimport java.util.Map;\n\n@Slf4j\npublic class HttpHelper {\n    private static final int DEFAULT_CONNECT_TIMEOUT = 1000000;\n\n    private SinkConfig sinkConfig;\n\n    public HttpHelper() {}\n\n    public HttpHelper(SinkConfig sinkConfig) {\n        this.sinkConfig = sinkConfig;\n    }\n\n    public HttpEntity getHttpEntity(CloseableHttpResponse resp) {\n        int code = resp.getStatusLine().getStatusCode();\n        if (HttpStatus.SC_OK != code) {\n            log.warn(\"Request failed with code:{}\", code);\n            return null;\n        }\n        HttpEntity respEntity = resp.getEntity();\n        if (null == respEntity) {\n            log.warn(\"Request failed with empty response.\");\n            return null;\n        }\n        return respEntity;\n    }\n\n    public String doHttpPost(String postUrl, Map<String, String> header, String postBody)\n            throws IOException {\n        log.info(\"Executing POST from {}.\", postUrl);\n        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {\n            HttpPost httpPost = new HttpPost(postUrl);\n            if (null != header) {\n                for (Map.Entry<String, String> entry : header.entrySet()) {\n                    httpPost.setHeader(entry.getKey(), String.valueOf(entry.getValue()));","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client/HttpHelper.java#L44-L80","documentation":"HttpHelper.getHttpEntity inspects the HTTP status of a StarRocks response; when the status code is not 200 it logs this warning and returns null. The caller is expected to treat null as a failed request. It is a warning log rather than an exception — the failure surfaces when the caller dereferences null or reports failure.","triggerScenarios":"Any HTTP request through HttpHelper that receives a non-200 status code, e.g. StarRocks returning 404 (wrong table/db), 401/407 (auth/proxy), 500 (server-side error), or load balancer errors.","commonSituations":"Misconfigured StarRocks FE/BE host or port; wrong database/table name; missing basic-auth credentials; proxy returning 407; StarRocks overloaded returning 5xx.","solutions":["Log/inspect the actual status code to identify 4xx vs 5xx","Fix the StarRocks endpoint URL, credentials, or database/table names","Check StarRocks server health and FE/BE availability","Add retry logic for transient 5xx responses"],"exampleFix":"// before\nHttpEntity entity = httpHelper.getHttpEntity(resp);\nif (entity == null) { /* silent failure */ }\n// after\nHttpEntity entity = httpHelper.getHttpEntity(resp);\nif (entity == null) {\n    int code = resp.getStatusLine().getStatusCode();\n    throw new IOException(\"StarRocks request failed, HTTP code=\" + code);\n}","handlingStrategy":"type-guard","validationCode":"// Pre-flight check of the StarRocks endpoint\nint status = probeHttpStatus(starRocksUrl, credentials);\nif (status != 200) throw new IllegalStateException(\"StarRocks endpoint returned \" + status);","typeGuard":"HttpEntity entity = httpHelper.getHttpEntity(resp);\nif (entity == null) { // treat as failure\n    throw new IOException(\"StarRocks request failed (non-200 or empty body)\");\n}","tryCatchPattern":null,"preventionTips":["Always null-check the return value of getHttpEntity and its callers","Log the actual HTTP status code for diagnostics","Verify StarRocks host/port/db/table config before running jobs","Handle 401/407 by checking credentials and proxy settings first"],"tags":["http","starrocks","status-code"],"backgroundTag":"http-error-status","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}