pentaho/pentaho-kettle · error · RuntimeException

Encountered error trying to read input

Error message

Encountered error trying to read input

What it means

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.

Solutions

  1. Run the import in an interactive terminal with working stdin.
  2. Use non-interactive flags/options (e.g. preset replace/continue-on-error decisions) so the prompt is never reached.
  3. Pipe predetermined answers into stdin (e.g. echo yes | import ...) if automation is required.
  4. Catch the RuntimeException around the import call and fall back to a non-interactive policy.

Example fix

// before
importer.runImportWithPrompt(); // blocks on reader.readLine()
// after
String answer = System.console() != null ? null : "no"; // non-interactive default
importer.setNonInteractiveAnswer(answer);
importer.runImportWithPrompt();
Defensive patterns

Strategy: try-catch

Validate before calling

if (System.console() == null) {
  // non-interactive environment: skip prompts, use preset answers
  importer.setNonInteractiveAnswer("no");
}

Try / catch

try {
  importJob.run();
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().contains("read input")) {
    log.error("stdin unavailable for interactive prompt; rerun with a TTY or preset answers");
  } else {
    throw e;
  }
}

Prevention

When it happens

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

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/7a1d945cecb16185. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/imp/Import.java:137

      return new OverwritePrompter() {
        private final String yes = BaseMessages.getString( PKG, "Import.Yes" );
        private final String no = BaseMessages.getString( PKG, "Import.No" );
        private final String none = BaseMessages.getString( PKG, "Import.None" );
        private final String all = BaseMessages.getString( PKG, "Import.All" );
        private final String prompt = "[" + yes + "," + no + "," + none + "," + all + "]";

        @Override
        public boolean overwritePrompt( String message, String rememberText, String rememberPropertyName ) {
          log.logBasic( message );
          String line;
          Boolean result = null;
          boolean remember = false;
          while ( result == null ) {
            log.logBasic( prompt );
            try {
              line = reader.readLine().trim();
            } catch ( IOException e ) {
              throw new RuntimeException( BaseMessages.getString( PKG, "Import.CouldntReadline" ) );
            }
            if ( line.equalsIgnoreCase( yes ) || line.equalsIgnoreCase( all ) ) {
              result = true;
            } else if ( line.equalsIgnoreCase( no ) || line.equalsIgnoreCase( none ) ) {
              result = false;
            }
            if ( line.equalsIgnoreCase( all ) || line.equalsIgnoreCase( none ) ) {
              remember = true;
            }
          }
          Props.getInstance().setProperty( rememberPropertyName, ( !remember ) ? "Y" : "N" );
          return result;
        }
      };
    }
  }

  public static void main( String[] a ) throws KettleException {

View on GitHub (pinned to f3058517a1)