{"record":{"id":"7a1d945cecb16185","repo":"pentaho/pentaho-kettle","slug":"encountered-error-trying-to-read-input","errorCode":null,"errorMessage":"Encountered error trying to read input","messagePattern":"Encountered error trying to read input","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/imp/Import.java","lineNumber":137,"sourceCode":"      return new OverwritePrompter() {\n        private final String yes = BaseMessages.getString( PKG, \"Import.Yes\" );\n        private final String no = BaseMessages.getString( PKG, \"Import.No\" );\n        private final String none = BaseMessages.getString( PKG, \"Import.None\" );\n        private final String all = BaseMessages.getString( PKG, \"Import.All\" );\n        private final String prompt = \"[\" + yes + \",\" + no + \",\" + none + \",\" + all + \"]\";\n\n        @Override\n        public boolean overwritePrompt( String message, String rememberText, String rememberPropertyName ) {\n          log.logBasic( message );\n          String line;\n          Boolean result = null;\n          boolean remember = false;\n          while ( result == null ) {\n            log.logBasic( prompt );\n            try {\n              line = reader.readLine().trim();\n            } catch ( IOException e ) {\n              throw new RuntimeException( BaseMessages.getString( PKG, \"Import.CouldntReadline\" ) );\n            }\n            if ( line.equalsIgnoreCase( yes ) || line.equalsIgnoreCase( all ) ) {\n              result = true;\n            } else if ( line.equalsIgnoreCase( no ) || line.equalsIgnoreCase( none ) ) {\n              result = false;\n            }\n            if ( line.equalsIgnoreCase( all ) || line.equalsIgnoreCase( none ) ) {\n              remember = true;\n            }\n          }\n          Props.getInstance().setProperty( rememberPropertyName, ( !remember ) ? \"Y\" : \"N\" );\n          return result;\n        }\n      };\n    }\n  }\n\n  public static void main( String[] a ) throws KettleException {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/imp/Import.java#L119-L155","documentation":"Import.overwritePrompt reads confirmation lines from the console reader inside a loop until a yes/no/all/none answer is given. If reader.readLine() throws IOException, it rethrows it as a RuntimeException with the localized message \"Encountered error trying to read input\" (Import.CouldntReadline). It means stdin became unreadable during the interactive overwrite prompt.","triggerScenarios":"Running the import in an environment where stdin is closed, redirected from an unreadable stream, or the underlying console/pipe breaks while the prompt waits for y/n input.","commonSituations":"Running the import non-interactively (no TTY, stdin from /dev/null or an empty pipe); CI/scheduled jobs where no operator can answer the prompt; terminal disconnect mid-import.","solutions":["Run the import in an interactive terminal with working stdin.","Use non-interactive flags/options (e.g. preset replace/continue-on-error decisions) so the prompt is never reached.","Pipe predetermined answers into stdin (e.g. echo yes | import ...) if automation is required.","Catch the RuntimeException around the import call and fall back to a non-interactive policy."],"exampleFix":"// before\nimporter.runImportWithPrompt(); // blocks on reader.readLine()\n// after\nString answer = System.console() != null ? null : \"no\"; // non-interactive default\nimporter.setNonInteractiveAnswer(answer);\nimporter.runImportWithPrompt();","handlingStrategy":"try-catch","validationCode":"if (System.console() == null) {\n  // non-interactive environment: skip prompts, use preset answers\n  importer.setNonInteractiveAnswer(\"no\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  importJob.run();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"read input\")) {\n    log.error(\"stdin unavailable for interactive prompt; rerun with a TTY or preset answers\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Never run interactive imports from cron/CI without preset answers","Check System.console() != null before prompting flows","Pipe answers (echo yes |) when automating"],"tags":["io","stdin","interactive-prompt"],"backgroundTag":"file-read-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}