{"record":{"id":"54c774019def02cf","repo":"apache/maven","slug":"unable-to-promptforpassword","errorCode":null,"errorMessage":"Unable to promptForPassword","messagePattern":"Unable to promptForPassword","errorType":"exception","errorClass":"PrompterException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/internal/compat/interactivity/LegacyPlexusInteractivity.java","lineNumber":138,"sourceCode":"            throw new PrompterException(\"Unable to prompt\", e);\n        }\n    }\n\n    @Override\n    public String prompt(String message, List possibleValues, String defaultReply) throws PrompterException {\n        try {\n            return prompter.prompt(message, possibleValues, defaultReply);\n        } catch (org.apache.maven.api.services.PrompterException e) {\n            throw new PrompterException(\"Unable to prompt\", e);\n        }\n    }\n\n    @Override\n    public String promptForPassword(String message) throws PrompterException {\n        try {\n            return prompter.promptForPassword(message);\n        } catch (org.apache.maven.api.services.PrompterException e) {\n            throw new PrompterException(\"Unable to promptForPassword\", e);\n        }\n    }\n\n    @Override\n    public void showMessage(String message) throws PrompterException {\n        try {\n            prompter.showMessage(message);\n        } catch (org.apache.maven.api.services.PrompterException e) {\n            throw new PrompterException(\"Unable to showMessage\", e);\n        }\n    }\n}\n","sourceCodeStart":120,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/internal/compat/interactivity/LegacyPlexusInteractivity.java#L120-L151","documentation":"Thrown when a masked password prompt fails. LegacyPlexusInteractivity.promptForPassword(message) delegates to prompter.promptForPassword and wraps any org.apache.maven.api.services.PrompterException in the legacy PrompterException with message 'Unable to promptForPassword'. Like the other prompt methods, the root cause is console/stdin unavailability or an I/O failure during the secure read.","triggerScenarios":"Calling promptForPassword(message) when no console is attached, stdin hits EOF, or the underlying secure prompt implementation throws (e.g., Console.readLine returning null in a headless JVM).","commonSituations":"Legacy plugins asking for credentials (repository passwords, GPG passphrases) via the old Prompter inside CI; docker/daemonized Maven runs without a TTY; unattended builds reaching a credential prompt.","solutions":["Supply credentials non-interactively: settings.xml <server> entries, ~/.m2 settings security, or environment variables instead of prompting","Run in batch mode (-B) and ensure the build never reaches an interactive password prompt","Catch PrompterException and fail with an actionable message telling the operator how to provide the credential","If interactive entry is required, run from a real terminal with stdin open"],"exampleFix":"// before\nString pwd = prompter.promptForPassword(\"Repository password:\");\n// after\nString pwd;\ntry {\n    pwd = prompter.promptForPassword(\"Repository password:\");\n} catch (PrompterException e) {\n    pwd = System.getenv(\"REPO_PASSWORD\"); // CI: read from env instead\n    if (pwd == null) throw new IllegalStateException(\"No password source available\", e);\n}","handlingStrategy":"try-catch","validationCode":"boolean canPromptSecurely = System.console() != null; // Console is required for masked reads in most impls","typeGuard":null,"tryCatchPattern":"try {\n    return prompter.promptForPassword(message);\n} catch (PrompterException e) {\n    throw new IllegalStateException(\"Password prompt failed; set REPO_PASSWORD env var or configure settings.xml\", e);\n}","preventionTips":["Never rely on interactive passwords in CI; use settings.xml servers or env-based credential providers","Check System.console() before prompting for secrets","Fail fast with instructions when no credential source is available"],"tags":["maven","interactivity","password","credentials","legacy","no-tty"],"backgroundTag":"interactive-prompt-unavailable","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}