{"record":{"id":"ef5fde22922c9364","repo":"shwenzhang/AndResGuard","slug":"failed-to-read-description-console-closed","errorCode":null,"errorMessage":"Failed to read ${description}: console closed","messagePattern":"Failed to read (.+?): console closed","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/apksigner/PasswordRetriever.java","lineNumber":288,"sourceCode":"    //     -alias test\n    //   generates a keystore and key which decrypt only with\n    //   \"\\u0061\\u0062\\u00c2\\u00a1\\u00c3\\u00a4\\u00d1\\u008e\\u0031\"\n    // * keytool -genkey -v -keystore native.jks -keyalg RSA -keysize 2048 -validity 10000\n    //     -alias test\n    //   generates a keystore and key which decrypt only with\n    //   \"\\u0061\\u0062\\u00a1\\u00e4\\u044e\\u0031\"\n\n    assertNotClosed();\n    if (spec.startsWith(\"pass:\")) {\n      char[] pwd = spec.substring(\"pass:\".length()).toCharArray();\n      return getPasswords(pwd);\n    } else if (SPEC_STDIN.equals(spec)) {\n      Console console = System.console();\n      if (console != null) {\n        // Reading from console\n        char[] pwd = console.readPassword(description + \": \");\n        if (pwd == null) {\n          throw new IOException(\"Failed to read \" + description + \": console closed\");\n        }\n        return getPasswords(pwd);\n      } else {\n        // Console not available -- reading from redirected input\n        System.out.println(description + \": \");\n        byte[] encodedPwd = readEncodedPassword(System.in);\n        if (encodedPwd.length == 0) {\n          throw new IOException(\"Failed to read \" + description + \": standard input closed\");\n        }\n        // By default, textual input obtained via standard input is supposed to be decoded\n        // using the in JVM default character encoding but we also try the console's\n        // encoding just in case.\n        return getPasswords(encodedPwd, Charset.defaultCharset(), CONSOLE_CHARSET);\n      }\n    } else if (spec.startsWith(\"file:\")) {\n      String name = spec.substring(\"file:\".length());\n      File file = new File(name).getCanonicalFile();\n      InputStream in = mFileInputStreams.get(file);","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/apksigner/PasswordRetriever.java#L270-L306","documentation":"Thrown by PasswordRetriever.getPasswords when the password spec is 'pass:'-style? No — this fires for a console-backed spec: System.console() returned a Console but console.readPassword returned null, meaning the terminal/console was closed or unavailable so the secret (keystore or key password) could not be read interactively. It is a sentinel IOException wrapping an environment problem, not a wrong password.","triggerScenarios":"Thrown at AndResGuard-core/src/main/java/apksigner/PasswordRetriever.java:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the program is not run in an environment without an interactive console when pass:console password specs are used (e.g. run from a real terminal, not a detached/subprocess without a TTY)","If console input is unavailable, supply the password via an alternative spec such as pass:<password>, file:<path>, or env:<variable>","Check that the JVM's System.console() is non-null before relying on console-based password prompts"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}