apache/maven · error · SecDispatcherException

Could not collect the password

Error message

Could not collect the password

What it means

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.

Source

Thrown at impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/ConsolePasswordPrompt.java:66

    }

    @Override
    public String description() {
        return "Secure console password prompt";
    }

    @Override
    public Optional<String> configTemplate() {
        return Optional.empty();
    }

    @Override
    public String handle(String config) throws SecDispatcherException {
        if (NAME.equals(config)) {
            try {
                return prompter.promptForPassword("Enter the master password: ");
            } catch (PrompterException e) {
                throw new SecDispatcherException("Could not collect the password", e);
            }
        }
        return null;
    }

    @Override
    public SecDispatcher.ValidationResponse validateConfiguration(String config) {
        if (NAME.equals(config)) {
            return new SecDispatcher.ValidationResponse(getClass().getSimpleName(), true, Map.of(), List.of());
        }
        return null;
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Run the command in a real interactive terminal and type the master password at the prompt.
  2. Create the master password once interactively, keep the resulting ~/.m2/settings-security.xml, and reuse it in automation instead of prompting.
  3. For scripted flows on Linux, allocate a pseudo-TTY: `script -qec 'mvn enc ...' /dev/null`.
  4. For remote runs use `ssh -t` so a TTY is allocated.

Example fix

# before: no TTY, the prompter fails
mvn enc < /dev/null

# after: interactive terminal, password typed at the hidden prompt
mvn enc
Defensive patterns

Strategy: try-catch

Try / catch

try {
    masterSource.handle("console-prompt");
} catch (SecDispatcherException e) {
    // prompt failed: no TTY / closed stdin - fall back to pre-provisioned settings-security.xml
    abortWithHint("Run in an interactive terminal or provision settings-security.xml", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: Automating server-password encryption in pipelines where nobody can type; IDE run consoles that are not real TTYs; headless containers.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/c2615ddbebeaa4d3. Report an issue: GitHub.