{"record":{"id":"f59c1643fe74989f","repo":"pentaho/pentaho-kettle","slug":"could-not-get-the-groups-of-the-current-user-error-code","errorCode":null,"errorMessage":"Could not get the groups  of the current user (error code: )","messagePattern":"Could not get the groups  of the current user \\(error code: \\)","errorType":"exception","errorClass":"JSchException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/vfs/SftpFileSystemWindows.java","lineNumber":106,"sourceCode":"\n  @Override\n  public boolean isReleaseable() {\n    return !isOpen() && ( null == openStreamCount || openStreamCount.get() == 0 );\n  }\n\n  /**\n   * get user group on remote windows host\n   *\n   * @return list of groups + user person\n   * @throws JSchException\n   * @throws IOException\n   */\n  List<String> getUserGroups() throws JSchException, IOException {\n    if ( userGroups == null ) {\n      StringBuilder output = new StringBuilder();\n      int code = this.executeCommandWinClass( WHO_AMI_GROUPS_FO_LIST, output );\n      if ( code != 0 ) {\n        throw new JSchException( \"Could not get the groups  of the current user (error code: \" + code + \")\" );\n      }\n\n      this.userGroups = getUserGroups( output.toString() );\n      userGroups.add( getUser() );\n    }\n    return this.userGroups;\n  }\n\n  /**\n   * cut user groups from output whoami\n   *\n   * @param commandOutput output from whoami\n   * @return list of user groups\n   */\n  private List<String> getUserGroups( String commandOutput ) {\n    List<String> result = new ArrayList<>();\n    int startIndex = 0;\n    int endIndex;","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/vfs/SftpFileSystemWindows.java#L88-L124","documentation":"Thrown by SftpFileSystemWindows.getUserGroups() when the remote Windows 'whoami /groups' command (WHO_AMI_GROUPS_FO_LIST) exits with a non-zero code, so the current user's group list cannot be collected for SFTP VFS authorization logic. The thrown JSchException embeds the exit code (the placeholder '(' in the stored message is filled at runtime).","triggerScenarios":"Calling getUserGroups() (directly or via userGroups) over a Windows SFTP connection when the remote 'whoami /groups' command fails to execute or returns a non-zero exit code.","commonSituations":"Remote shell restricted or not cmd.exe; whoami blocked by policy or antivirus; user lacks rights to enumerate groups; custom SSH server on Windows not supporting the Win-class command execution path.","solutions":["SSH into the host manually and run 'whoami /groups' to see the actual failure and exit code","Ensure the SSH server spawns a cmd/Windows-class shell (this class uses WinClass command execution) and the account can run whoami","Check server-side security policy/AV is not blocking whoami.exe for that account","Reconnect with a different account that can enumerate its group memberships","Catch the JSchException and degrade gracefully if group info is optional"],"exampleFix":"// before\nList<String> groups = fs.getUserGroups();\n// after\nList<String> groups;\ntry {\n  groups = fs.getUserGroups();\n} catch ( JSchException e ) {\n  log.logError( \"Unable to fetch remote user groups: \" + e.getMessage(), e );\n  groups = Collections.emptyList();\n}","handlingStrategy":"try-catch","validationCode":"// Prefer verifying connectivity first\n// ssh user@host \"whoami /groups\" && echo OK\n// If it fails remotely, getUserGroups() will throw.","typeGuard":null,"tryCatchPattern":"try {\n  List<String> groups = fs.getUserGroups();\n} catch ( JSchException e ) {\n  // parse error code from e.getMessage()\n  log.logError( \"Remote 'whoami /groups' failed: \" + e.getMessage(), e );\n} catch ( IOException e ) {\n  log.logError( \"IO failure reading group output: \" + e.getMessage(), e );\n}","preventionTips":["Verify the remote SSH server on Windows exposes a cmd-class shell","Confirm the login account can run whoami manually before configuring PDI","Keep antivirus/policy exclusions for whoami.exe","Test the SFTP connection in a job before workflows that depend on group info"],"tags":["sftp","vfs","remote-execution","windows"],"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"}