{"record":{"id":"a7199bd0cb12098c","repo":"apache/hadoop","slug":"no-console-available-for-checking-user","errorCode":null,"errorMessage":"No console available for checking user.","messagePattern":"No console available for checking user\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java","lineNumber":359,"sourceCode":"        }\n      } catch (IOException e) {\n        e.printStackTrace(getErr());\n      }\n      return true;\n    }\n\n    public void execute() throws IOException, NoSuchAlgorithmException {\n      if (alias.equals(\"-help\")) {\n        doHelp();\n        return;\n      }\n      warnIfTransientProvider();\n      getOut().println(\"Checking aliases for CredentialProvider: \" +\n          provider.toString());\n      try {\n        PasswordReader c = getPasswordReader();\n        if (c == null) {\n          throw new IOException(\"No console available for checking user.\");\n        }\n\n        char[] password = null;\n        if (value != null) {\n          // testing only\n          password = value.toCharArray();\n        } else {\n          password = c.readPassword(\"Enter alias password: \");\n        }\n        CredentialEntry credentialEntry = provider.getCredentialEntry(alias);\n        if(credentialEntry == null) {\n          // Fail the password match when alias not found\n          getOut().println(\"Password match failed for \" + alias + \".\");\n        } else {\n          char[] storePassword = credentialEntry.getCredential();\n          String beMatch =\n              Arrays.equals(storePassword, password) ? \"success\" : \"failed\";\n","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialShell.java#L341-L377","documentation":"The 'hadoop credential check <alias>' command must read a password interactively to compare it against the stored credential; PasswordReader wraps System.console(), and when the JVM has no console (stdin piped/redirected, no TTY) it is null, so the command aborts before checking anything.","triggerScenarios":"Running 'hadoop credential check <alias> -provider ...' from a pipe, script, cron, CI runner, ssh with no tty, or an IDE console - anywhere System.console() returns null.","commonSituations":"Automated verification pipelines calling the check command; Docker containers without -t; nohup/background runs.","solutions":["Run the command in a real interactive terminal (ssh -t for remote)","Use the non-interactive flag: hadoop credential check <alias> -value <secret> -provider <path> (value is compared instead of prompted)","For automation, drop the shell: read via the API provider.getCredentialEntry(alias) and compare in code"],"exampleFix":"# before (no TTY -> fails)\nhadoop credential check my.alias -provider jceks://file/creds.jceks < /dev/null\n\n# after (non-interactive value check)\nhadoop credential check my.alias -value 's3cret' -provider jceks://file/creds.jceks","handlingStrategy":"validation","validationCode":"// Guard any wrapper around the shell: console or explicit value, never neither\nif (System.console() == null && value == null) {\n  throw new IllegalStateException(\n      \"'hadoop credential check' needs a TTY or an explicit -value argument\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  runShell(\"credential\", \"check\", alias, \"-provider\", providerUri);\n} catch (IOException ex) {\n  if (ex.getMessage().contains(\"No console available\")) {\n    // rerun with -value or allocate a TTY (ssh -t / docker exec -it)\n  } else { throw ex; }\n}","preventionTips":["In scripts and CI, always pass -value for 'credential check' instead of relying on prompts","Wrap TTY-dependent commands with a System.console() null-check in orchestration code","Prefer the provider Java API for automated credential verification"],"tags":["hadoop","credential-shell","console","no-tty","interactive"],"backgroundTag":"console-not-available","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}