{"record":{"id":"7b4c7259210e3da1","repo":"pentaho/pentaho-kettle","slug":"there-were-conversionexceptions-size-conversion-errors-on","errorCode":null,"errorMessage":"There were \" + conversionExceptions.size() + \" conversion errors on line \" + getLinesInput()","messagePattern":"There were \" \\+ conversionExceptions\\.size\\(\\) \\+ \" conversion errors on line \" \\+ getLinesInput\\(\\)","errorType":"exception","errorClass":"KettleConversionException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java","lineNumber":851,"sourceCode":"        if ( meta.isLazyConversionActive() ) {\n          outputRowData[ data.filenameFieldIndex ] = data.binaryFilename;\n        } else {\n          outputRowData[ data.filenameFieldIndex ] = data.filenames[ data.filenr - 1 ];\n        }\n      }\n\n      if ( data.isAddingRowNumber ) {\n        outputRowData[ data.rownumFieldIndex ] = data.rowNumber++;\n      }\n\n      if ( !ignoreEnclosures ) {\n        incrementLinesInput();\n      }\n\n      if ( conversionExceptions != null && conversionExceptions.size() > 0 ) {\n        // Forward the first exception\n        //\n        throw new KettleConversionException(\n          \"There were \" + conversionExceptions.size() + \" conversion errors on line \" + getLinesInput(),\n          conversionExceptions, exceptionFields, outputRowData );\n      }\n\n      return outputRowData;\n    } catch ( KettleConversionException e ) {\n      throw e;\n    } catch ( IOException e ) {\n      throw new KettleFileException( \"Exception reading line using NIO\", e );\n    }\n  }\n\n\n  public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (CsvInputMeta) smi;\n    data = (CsvInputData) sdi;\n\n    if ( super.init( smi, sdi ) ) {","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java#L833-L869","documentation":"When a line contains values that cannot be converted to the declared field types, the step collects KettleConversionException items per field; instead of stopping at the first, it aggregates them and throws a KettleConversionException reporting the total count of conversion errors and the line number (getLinesInput). The first exception and the list of failing fields accompany the error.","triggerScenarios":"readOneRow finishes converting a line and conversionExceptions is non-empty: e.g. a non-numeric string mapped to a Number field, malformed dates, or strings longer than the declared length with strict type conversion enabled.","commonSituations":"CSV data quality issues: empty or 'N/A' values in numeric columns, locale-dependent decimal separators, date formats not matching the field's format mask; wrong type declared in the step's field definitions.","solutions":["Fix the offending data at line 'linesInput' reported in the message, or correct the field's type/format mask in the step's Fields tab.","Set a conversion mask (format) matching the actual data, e.g. yyyy/MM/dd for dates or the right decimal separator.","Enable error handling on the step (right-click → Define error handling) to route bad lines to an error stream instead of failing.","Set the field type to String if no numeric/date conversion is actually needed."],"exampleFix":"// before\nfield \"amount\", type=Number, format=(none)  // data: \"1.234,56\"\n// after\nfield \"amount\", type=Number, format=\"#.###,##\"  // or fix source data","handlingStrategy":"try-catch","validationCode":"// validate numeric/date columns against their masks before the run\nfor (String v : row) {\n  if (fieldType.equals(\"Number\") && !v.isEmpty()) Double.valueOf(v.replace(',', '.')); // throws if invalid\n}","typeGuard":null,"tryCatchPattern":"try { ... } catch (KettleConversionException e) {\n  logError(\"Line \" + e.getLines() + \": conversion failed for fields \" + java.util.Arrays.toString(e.getFields()), e);\n  // enable step error handling to route bad rows instead of failing\n  setErrors(1);\n}","preventionTips":["Define explicit conversion masks matching the data (dates, decimals)","Right-click the step → Define error handling to divert bad rows","Fix data quality at the source or add a Data Cleansing step","Set fields to String when conversion is unnecessary"],"tags":["kettle","pentaho","data-conversion","type-mismatch"],"backgroundTag":"type-mismatch","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"}