{"record":{"id":"76ba7e288273ed38","repo":"pentaho/pentaho-kettle","slug":"httppost-exception-illegalstatuscode","errorCode":"HTTPPOST.Exception.IllegalStatusCode","errorMessage":"HTTPPOST.Exception.IllegalStatusCode","messagePattern":"HTTPPOST\\.Exception\\.IllegalStatusCode","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/httppost/HTTPPOST.java","lineNumber":258,"sourceCode":"        long responseTime = System.currentTimeMillis() - startTime;\n\n        if ( isDetailed() ) {\n          logDetailed( BaseMessages.getString( PKG, \"HTTPPOST.Log.ResponseTime\", responseTime, data.realUrl ) );\n        }\n\n        // Display status code\n        if ( isDebug() ) {\n          logDebug( BaseMessages.getString( PKG, \"HTTPPOST.Log.ResponseCode\", String.valueOf( statusCode ) ) );\n        }\n\n        String body;\n        String headerString = \"\";\n        switch ( statusCode ) {\n          case HttpURLConnection.HTTP_UNAUTHORIZED:\n            throw new KettleStepException( BaseMessages\n              .getString( PKG, \"HTTPPOST.Exception.Authentication\", data.realUrl ) );\n          case -1:\n            throw new KettleStepException( BaseMessages\n              .getString( PKG, \"HTTPPOST.Exception.IllegalStatusCode\", data.realUrl ) );\n          case HttpURLConnection.HTTP_NO_CONTENT:\n            body = \"\";\n            break;\n          default:\n            HttpEntity entity = httpResponse.getEntity();\n            if ( entity != null ) {\n              body = EntityUtils.toString( entity );\n            } else {\n              body = \"\";\n            }\n            Header[] headers = searchForHeaders( httpResponse );\n            // Use request encoding if specified in component to avoid strange response encodings\n            // See PDI-3815\n\n            JSONObject json = new JSONObject();\n            for ( Header header : headers ) {\n              Object previousValue = json.get( header.getName() );","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/httppost/HTTPPOST.java#L240-L276","documentation":"The HTTP POST step got a response with no valid status line (statusCode == -1), which the step treats as an illegal/unknown status and throws KettleStepException 'HTTPPOST.Exception.IllegalStatusCode' naming the URL. This usually indicates the connection failed before a real HTTP response arrived or the response was not valid HTTP.","triggerScenarios":"callHTTPPOST switch on statusCode hits case -1 — the HTTP method executed but produced no status code (connection reset, malformed/non-HTTP response, connection closed prematurely by server or proxy).","commonSituations":"Server closing the connection before responding; a proxy or load balancer returning a non-HTML garbage response; HTTPS endpoint hit with http:// (or vice versa) yielding a protocol error; server crash mid-request.","solutions":["Check connectivity to the host/port and confirm the protocol scheme (http vs https) matches the server.","Inspect server/proxy logs around the request time for resets or dropped connections.","Retry the request; transient network failures commonly surface as status -1.","Capture the raw response with curl or tcpdump to see what the endpoint actually returns.","Ensure any proxy in front of the service is configured to pass through valid HTTP responses."],"exampleFix":"// before\nString url = \"http://secure.example.com/api\"; // server is HTTPS-only, response is not valid HTTP\n// after\nString url = \"https://secure.example.com/api\";","handlingStrategy":"retry","validationCode":"// pre-flight: ensure the endpoint answers with a valid HTTP status before running\ncurl -s -o /dev/null -w '%{http_code}' --max-time 10 https://host/api  # must return a numeric HTTP code","typeGuard":null,"tryCatchPattern":"try { outputRowData = callHTTPPOST( ... ); } catch ( KettleStepException e ) {\n  if ( e.getMessage().contains( \"IllegalStatusCode\" ) ) {\n    logError( \"No valid HTTP status from \" + url + \"; check scheme/proxy/server health\" );\n    // retry with backoff or send row to error stream\n  } else throw e;\n}","preventionTips":["Always use the correct scheme (https for TLS endpoints)","Monitor target service health and proxy behavior","Set connect/read timeouts so dead connections fail fast and retry cleanly","Capture raw responses when diagnosing to distinguish reset vs malformed response"],"tags":["http","network","invalid-response","kettle"],"backgroundTag":"unexpected-http-status","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}