{"record":{"id":"0d2e0884a968feea","repo":"apache/maven","slug":"unable-to-prompt","errorCode":null,"errorMessage":"Unable to prompt","messagePattern":"Unable to prompt","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/internal/compat/interactivity/LegacyPlexusInteractivity.java","lineNumber":57,"sourceCode":" */\n@Experimental\n@Named\n@Singleton\n@Priority(10)\npublic class LegacyPlexusInteractivity implements Prompter, InputHandler, OutputHandler {\n    private final org.apache.maven.api.services.Prompter prompter;\n\n    @Inject\n    public LegacyPlexusInteractivity(org.apache.maven.api.services.Prompter prompter) {\n        this.prompter = prompter;\n    }\n\n    @Override\n    public String readLine() throws IOException {\n        try {\n            return prompter.prompt(null);\n        } catch (org.apache.maven.api.services.PrompterException e) {\n            throw new IOException(\"Unable to prompt\", e);\n        }\n    }\n\n    @Override\n    public String readPassword() throws IOException {\n        try {\n            return prompter.promptForPassword(null);\n        } catch (org.apache.maven.api.services.PrompterException e) {\n            throw new IOException(\"Unable to prompt\", e);\n        }\n    }\n\n    @Override\n    public List<String> readMultipleLines() throws IOException {\n        List<String> lines = new ArrayList<>();\n        for (String line = readLine(); line != null && !line.isEmpty(); line = readLine()) {\n            lines.add(line);\n        }","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/internal/compat/interactivity/LegacyPlexusInteractivity.java#L39-L75","documentation":"LegacyPlexusInteractivity.readLine() bridges legacy components to the new Prompter SPI by calling prompter.prompt(null); any PrompterException is converted into IOException('Unable to prompt'). It fires when a prompt cannot be delivered at all: no console attached, stdin at EOF, or the prompter implementation itself failing - not when the user types a wrong answer.","triggerScenarios":"A legacy maven-compat component calling readLine() where System.console() is null (piped stdin, CI service, daemon), after stdin reaches EOF, or where no usable Prompter implementation is registered in the container.","commonSituations":"CI running an old plugin that asks for input (GPG passphrase, SCM login) with stdin closed; Maven run as a service; piping input like `echo | mvn ...` where EOF arrives before the prompt is answered.","solutions":["Run the build in a real terminal when the tool genuinely needs interactive input","Replace the prompt with configuration: pass values via settings.xml, -D properties, or environment variables (e.g. gpg.passphrase)","Run mvn -B/--batch-mode with credentials fully preconfigured so nothing ever prompts","If stdin must be piped, ensure it provides the expected line: printf 'answer\\n' | mvn ..."],"exampleFix":"# before: CI hangs/prompts and dies on EOF\nmvn release:prepare\n# after: batch mode with preconfigured values\nmvn -B -Dgpg.passphrase=${env.GPG_PASSPHRASE} release:prepare","handlingStrategy":"try-catch","validationCode":"if (System.console() == null) {\n    // no interactive console: do not call readLine(); use config/env instead\n}","typeGuard":null,"tryCatchPattern":"Catch IOException from readLine(); when the message is 'Unable to prompt', switch to a non-interactive source (property, environment variable, settings.xml) rather than retrying the prompt.","preventionTips":["Design build steps to take secrets from settings.xml or the environment, never prompts.","Default to --batch-mode in CI and verify no plugin requires input.","Provide a Prompter implementation when embedding Maven in genuinely interactive applications."],"tags":["maven","prompter","interactivity","console","io","legacy-compat"],"backgroundTag":"prompter-unavailable","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}