{"record":{"id":"09f3701fb15e3eb6","repo":"pentaho/pentaho-kettle","slug":"http-exception-illegalstatuscode","errorCode":"HTTP.Exception.IllegalStatusCode","errorMessage":"HTTP.Exception.IllegalStatusCode","messagePattern":"HTTP\\.Exception\\.IllegalStatusCode","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/http/HTTP.java","lineNumber":177,"sourceCode":"        }\n        // calculate the responseTime\n        long responseTime = System.currentTimeMillis() - startTime;\n        if ( log.isDetailed() ) {\n          log.logDetailed( BaseMessages.getString( PKG, \"HTTP.Log.ResponseTime\", responseTime, uri ) );\n        }\n        int statusCode = requestStatusCode( httpResponse );\n        // The status code\n        if ( isDebug() ) {\n          logDebug( BaseMessages.getString( PKG, \"HTTP.Log.ResponseStatusCode\", \"\" + statusCode ) );\n        }\n\n        String body;\n        switch ( statusCode ) {\n          case HttpURLConnection.HTTP_UNAUTHORIZED:\n            throw new KettleStepException( BaseMessages\n              .getString( PKG, \"HTTP.Exception.Authentication\", data.realUrl ) );\n          case -1:\n            throw new KettleStepException( BaseMessages\n              .getString( PKG, \"HTTP.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 = StringUtils.isEmpty( meta.getEncoding() ) ? EntityUtils.toString( entity ) : EntityUtils.toString( entity, meta.getEncoding() );\n            } else {\n              body = \"\";\n            }\n            break;\n        }\n\n        Header[] headers = searchForHeaders( httpResponse );\n\n        JSONObject json = new JSONObject();\n        for ( Header header : headers ) {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/http/HTTP.java#L159-L195","documentation":"When the HTTP response status code cannot be determined (statusCode == -1, typically meaning no valid response was received), callHttpService throws this KettleStepException for the target URL. It indicates a broken connection or protocol failure rather than a real HTTP status.","triggerScenarios":"callHttpService's switch hits case -1: the request failed to produce a status line — connection dropped, TLS handshake failure, or the executeMethod returned without a valid response.","commonSituations":"Target server closed the connection prematurely; SSL/TLS version or certificate mismatch; hostname resolves but nothing listening; firewall silently dropping the request; malformed response from a non-HTTP service on that port.","solutions":["Verify the server is reachable and serving HTTP on that URL/port","Test with curl -v to see connection/TLS errors directly","Check TLS: add the server certificate to the JVM truststore or correct the protocol (http vs https)","Fix proxy/firewall rules that drop or reset the connection","Confirm the URL points at an HTTP endpoint, not another protocol"],"exampleFix":"// before\nString realUrl = \"ftp://host/file\"; // non-HTTP endpoint → status -1\n// after\nString realUrl = \"https://host/api/file\";","handlingStrategy":"retry","validationCode":"// preflight reachability\nInetAddress addr = InetAddress.getByName( host );\ntry ( Socket s = new Socket() ) { s.connect( new InetSocketAddress( addr, port ), 5000 ); }","typeGuard":null,"tryCatchPattern":"int attempts = 0;\nwhile ( attempts < 3 ) {\n  try { runTransformation(); break; }\n  catch ( KettleStepException e ) {\n    if ( e.getMessage().contains( \"IllegalStatusCode\" ) && ++attempts < 3 ) {\n      Thread.sleep( 2000L * attempts ); continue; // transient connection failure\n    } throw e;\n  }\n}","preventionTips":["Validate URLs point at live HTTP endpoints (curl -v)","Fix TLS trust/protocol config to avoid dropped handshakes","Check firewalls/proxies that reset connections silently","Increase HttpClient timeouts for slow endpoints"],"tags":["kettle","pdi","http","network","status-code"],"backgroundTag":"http-request-failed","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"}