{"record":{"id":"682a8b2d63b677f7","repo":"pentaho/pentaho-kettle","slug":"textfilecsvimportprogressdialog-exception-errorscanningfile-682a8b","errorCode":null,"errorMessage":"TextFileCSVImportProgressDialog.Exception.ErrorScanningFile","messagePattern":"TextFileCSVImportProgressDialog\\.Exception\\.ErrorScanningFile","errorType":"exception","errorClass":"InvocationTargetException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/trans/steps/textfileinput/TextFileCSVImportProgressDialog.java","lineNumber":138,"sourceCode":"  public String open() {\n    return open( true );\n  }\n\n  /**\n   * @param failOnParseError if set to true, parsing failure on any line will cause parsing to be terminated; when\n   *                         set to false, parsing failure on a given line will not prevent remaining lines from\n   *                         being parsed - this allows us to analyze fields, even if some field is mis-configured\n   *                         and causes a parsing error for the values of that field.\n   */\n  @Override\n  public String open( final boolean failOnParseError ) {\n    IRunnableWithProgress op = new IRunnableWithProgress() {\n      public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {\n        try {\n          message = doScan( monitor, failOnParseError );\n        } catch ( Exception e ) {\n          e.printStackTrace();\n          throw new InvocationTargetException( e,\n            BaseMessages.getString( PKG, \"TextFileCSVImportProgressDialog.Exception.ErrorScanningFile\",\n              \"\" + rownumber, debug, e.toString() ) );\n        }\n      }\n    };\n\n    try {\n      ProgressMonitorDialog pmd = new ProgressMonitorDialog( shell );\n      pmd.run( true, true, op );\n    } catch ( InvocationTargetException e ) {\n      new ErrorDialog( shell,\n        BaseMessages.getString( PKG, \"TextFileCSVImportProgressDialog.ErrorScanningFile.Title\" ),\n        BaseMessages.getString( PKG, \"TextFileCSVImportProgressDialog.ErrorScanningFile.Message\" ), e );\n    } catch ( InterruptedException e ) {\n      new ErrorDialog( shell,\n        BaseMessages.getString( PKG, \"TextFileCSVImportProgressDialog.ErrorScanningFile.Title\" ),\n        BaseMessages.getString( PKG, \"TextFileCSVImportProgressDialog.ErrorScanningFile.Message\" ), e );\n    }","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/trans/steps/textfileinput/TextFileCSVImportProgressDialog.java#L120-L156","documentation":"TextFileCSVImportProgressDialog.run wraps the CSV scanning work (doScan) executed inside an Eclipse IRunnableWithProgress. Any exception during scanning is rethrown as an InvocationTargetException whose message is TextFileCSVImportProgressDialog.Exception.ErrorScanningFile, including the row number, debug info, and the underlying exception text, so the import-progress dialog can surface the failure to the user.","triggerScenarios":"Importing a CSV file in the Text File Input wizard when doScan fails — e.g. IO error reading the file, character encoding problems, or severe parse errors while counting rows/detecting types at the failing row.","commonSituations":"File locked by another process or removed mid-scan; wrong charset chosen (garbled bytes breaking parsing); corrupt file content; permission issues; extremely malformed quoting that breaks the tokenizer.","solutions":["Read the wrapped exception/row number in the dialog to locate the offending row and fix the data there","Choose the correct character encoding and format (delimiter, enclosure) in the import dialog","Confirm the file is readable, not locked, and not truncated mid-write","Preview the file first to let the wizard detect the proper format before full scan"],"exampleFix":"// before: wrong charset for a UTF-8 file\nString encoding = \"ISO-8859-1\"; // scan may blow up on multibyte chars\n// after\nString encoding = \"UTF-8\";","handlingStrategy":"try-catch","validationCode":"// Java: pre-check the CSV file before invoking the import wizard\njava.io.File f = new java.io.File( path );\nif ( !f.canRead() || f.length() == 0 ) throw new IllegalStateException( \"File unreadable: \" + path );","typeGuard":"boolean csvReadable = path != null && new java.io.File( path ).canRead();","tryCatchPattern":"try { runImportScan(); } catch ( InvocationTargetException e ) { log.error( \"Scan failed at row \" + e.getTargetException().getMessage(), e ); }","preventionTips":["Pick the correct encoding and delimiter before scanning","Ensure the file is not locked or being written while importing","Test with a preview/limited scan on large or suspect files"],"tags":["csv","file-scan","import","ui"],"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"}