{"record":{"id":"c2615ddbebeaa4d3","repo":"apache/maven","slug":"could-not-collect-the-password","errorCode":null,"errorMessage":"Could not collect the password","messagePattern":"Could not collect the password","errorType":"exception","errorClass":"SecDispatcherException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/ConsolePasswordPrompt.java","lineNumber":66,"sourceCode":"    }\n\n    @Override\n    public String description() {\n        return \"Secure console password prompt\";\n    }\n\n    @Override\n    public Optional<String> configTemplate() {\n        return Optional.empty();\n    }\n\n    @Override\n    public String handle(String config) throws SecDispatcherException {\n        if (NAME.equals(config)) {\n            try {\n                return prompter.promptForPassword(\"Enter the master password: \");\n            } catch (PrompterException e) {\n                throw new SecDispatcherException(\"Could not collect the password\", e);\n            }\n        }\n        return null;\n    }\n\n    @Override\n    public SecDispatcher.ValidationResponse validateConfiguration(String config) {\n        if (NAME.equals(config)) {\n            return new SecDispatcher.ValidationResponse(getClass().getSimpleName(), true, Map.of(), List.of());\n        }\n        return null;\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/ConsolePasswordPrompt.java#L48-L80","documentation":"The mvnenc password-encryption tool resolves the master password through sec dispatcher master sources; when settings-security.xml selects the 'console-prompt' source (ConsolePasswordPrompt, NAME = console-prompt), it calls prompter.promptForPassword and wraps any PrompterException as SecDispatcherException 'Could not collect the password'. The prompt itself failed - classically because no interactive console is attached. The password was never read, so encryption cannot proceed.","triggerScenarios":"Running the encryption tool with stdin closed or redirected (`< /dev/null`, piped input), under CI/cron with no TTY, over SSH without `-t`, or with a terminal the prompter implementation cannot drive.","commonSituations":"Automating server-password encryption in pipelines where nobody can type; IDE run consoles that are not real TTYs; headless containers.","solutions":["Run the command in a real interactive terminal and type the master password at the prompt.","Create the master password once interactively, keep the resulting ~/.m2/settings-security.xml, and reuse it in automation instead of prompting.","For scripted flows on Linux, allocate a pseudo-TTY: `script -qec 'mvn enc ...' /dev/null`.","For remote runs use `ssh -t` so a TTY is allocated."],"exampleFix":"# before: no TTY, the prompter fails\nmvn enc < /dev/null\n\n# after: interactive terminal, password typed at the hidden prompt\nmvn enc","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    masterSource.handle(\"console-prompt\");\n} catch (SecDispatcherException e) {\n    // prompt failed: no TTY / closed stdin - fall back to pre-provisioned settings-security.xml\n    abortWithHint(\"Run in an interactive terminal or provision settings-security.xml\", e);\n}","preventionTips":["Provision ~/.m2/settings-security.xml once interactively; never prompt from CI.","Use `ssh -t` or `script -qec` when a TTY is required remotely.","Detect non-interactive contexts (System.console() == null) before invoking the tool."],"tags":["maven","encryption","master-password","prompt","tty"],"backgroundTag":"password-prompt-no-tty","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}