prestodb/presto · error · RuntimeException
No console from which to read password
Error message
No console from which to read password
What it means
When --password is passed without a value (prompting mode) and no default password is configured, the CLI needs an interactive console to read the password securely. System.console() returns null in non-interactive environments (piped stdin, no TTY), so getPassword throws.
Source
Thrown at presto-cli/src/main/java/com/facebook/presto/cli/Console.java:171
return true;
}
finally {
exited.countDown();
interruptor.close();
}
}
private String getPassword()
{
checkState(clientOptions.user != null, "Username must be specified along with password");
String defaultPassword = System.getenv("PRESTO_PASSWORD");
if (defaultPassword != null) {
return defaultPassword;
}
java.io.Console console = System.console();
if (console == null) {
throw new RuntimeException("No console from which to read password");
}
char[] password = console.readPassword("Password: ");
if (password != null) {
return new String(password);
}
return "";
}
private static void runConsole(QueryRunner queryRunner, AtomicBoolean exiting)
{
try (TableNameCompleter tableNameCompleter = new TableNameCompleter(queryRunner);
LineReader reader = new LineReader(getHistory(), commandCompleter(), lowerCaseCommandCompleter(), tableNameCompleter)) {
tableNameCompleter.populateCache();
StringBuilder buffer = new StringBuilder();
while (!exiting.get()) {
// read a line of input from user
String prompt = PROMPT_NAME;
String schema = queryRunner.getSession().getSchema();View on GitHub (pinned to 55bb57d202)
Solutions
- Supply the password non-interactively: use --password <value> or set the password config so the prompt is skipped
- Allocate a TTY: run interactively or use docker exec -t / ssh -tt
- Use a keystore/token auth alternative that doesn't need a console prompt
Example fix
// before (CI, no TTY) presto --user admin --password --execute "SELECT 1" // after presto --user admin --password "$PRESTO_PASSWORD" --execute "SELECT 1"
Defensive patterns
Strategy: validation
Validate before calling
// Only prompt for password when a TTY exists if [ ! -t 0 ] && [ -z "$PRESTO_PASSWORD" ]; then echo "No TTY: set PRESTO_PASSWORD or pass --password explicitly" >&2; exit 1; fi
Try / catch
try { runCli(args); } catch (RuntimeException e) { if (e.getMessage().equals("No console from which to read password")) { /* fall back to env/config-provided credentials */ } else throw e; } Prevention
- In CI/cron, always supply credentials via config or flag value, never the prompt
- Use docker exec -t or a pseudo-TTY when interactive input is required
- Keep secrets out of logs when passing --password with a value
When it happens
Trigger: Running presto with a password-requiring --user and prompting --password flag while stdin is not a terminal: CI jobs, cron, subprocess with redirected stdin, docker exec without -t.
Common situations: Automated pipelines invoking the CLI non-interactively; Docker/supervisor contexts lacking a TTY; scripts piping SQL in via stdin while relying on password prompt.
Related errors
- both --execute and --file specified
- Error reading from file %s: %s
- not supported
- Interrupted while preprocessing query
- Error preprocessing query:
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/03243da475f68b95.
Report an issue: GitHub.