{"record":{"id":"0e5887cc9acd2f2f","repo":"pentaho/pentaho-kettle","slug":"ssh-connection-failed-session-is-null","errorCode":null,"errorMessage":"SSH connection failed - session is null","messagePattern":"SSH connection failed - session is null","errorType":"exception","errorClass":"SshConnectionException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/ssh/mina/MinaSshConnection.java","lineNumber":277,"sourceCode":"\n    if ( !connected ) {\n      if ( connectTimeout > 0 ) {\n        throw new SshTimeoutException( \"SSH connection timed out after \" + connectTimeout + \"ms\" );\n      }\n      throw new SshTimeoutException( \"SSH connection failed while waiting with no configured timeout\" );\n    }\n\n    if ( !cf.isConnected() ) {\n      Throwable cause = cf.getException();\n      throw new SshConnectionException( \"SSH connection failed\", cause );\n    }\n  }\n\n  private ClientSession establishSession( ConnectFuture cf ) throws SshConnectionException {\n    ClientSession s = cf.getSession();\n\n    if ( s == null ) {\n      throw new SshConnectionException( \"SSH connection failed - session is null\" );\n    }\n\n    return s;\n  }\n\n  private void authenticateSession() throws SshConnectionException {\n    log( DEBUG, \"Starting SSH authentication - Auth type: \" + config.getAuthType() );\n    boolean authed = tryPublicKeyAuthentication();\n\n    if ( !authed ) {\n      log( DEBUG, \"Public key authentication failed or not configured, trying password authentication\" );\n      authed = tryPasswordAuthentication();\n    }\n\n    if ( !authed ) {\n      log( ERROR, \"All SSH authentication methods failed\" );\n      throw new SshAuthenticationException( \"SSH authentication failed\" );\n    } else {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/ssh/mina/MinaSshConnection.java#L259-L295","documentation":"establishSession calls cf.getSession() after a successful connect but defends against the impossible-per-API case of a null ClientSession, throwing SshConnectionException('SSH connection failed - session is null'). This is an internal-invariant style check in MinaSshConnection; it indicates the MINA future reported connected but produced no session.","triggerScenarios":"connect() proceeds past waitForConnection with connected=true, yet ConnectFuture.getSession() returns null — effectively a MINA SSHD state anomaly or race in future completion.","commonSituations":"Rarely user-caused; seen with unusual MINA SSHD version behavior, race conditions in future completion, or custom/patched SSHD library builds.","solutions":["Log and report the MINA SSHD version in use; upgrade org.apache.sshd to a current release","Retry the connect — often transient state race","Check the full stack trace for a concurrent disconnect closing the session","Open an issue with the Pentaho Kettle project if reproducible"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// after connect()\nif ( !connection.isConnected() ) { throw new IllegalStateException( \"Connection not established; cannot use session\" ); }","typeGuard":null,"tryCatchPattern":"try { conn.connect(); }\ncatch ( SshConnectionException e ) {\n  if ( e.getMessage().contains( \"session is null\" ) ) { retryConnectWithBackoff( conn ); } // transient MINA state issue\n  else throw e;\n}","preventionTips":["Pin a recent, stable org.apache.sshd version","Retry connect once on this rare invariant failure","Report reproducible cases to the Pentaho Kettle project","Log the MINA SSHD version with connection attempts"],"tags":["ssh","mina-sshd","invariant"],"backgroundTag":"internal-invariant-violation","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"}