{"record":{"id":"8c300199ee3b2dbb","repo":"pentaho/pentaho-kettle","slug":"exception-reading-line-using-nio-s3csvinput","errorCode":null,"errorMessage":"Exception reading line using NIO","messagePattern":"Exception reading line using NIO","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"plugins/s3csvinput/core/src/main/java/org/pentaho/di/trans/steps/s3csvinput/S3CsvInput.java","lineNumber":522,"sourceCode":"\n      // Optionally add the current filename to the mix as well...\n      //\n      if ( meta.isIncludingFilename() && !Utils.isEmpty( meta.getFilenameField() ) ) {\n        if ( meta.isLazyConversionActive() ) {\n          outputRowData[outputIndex++] = data.binaryFilename;\n        } else {\n          outputRowData[outputIndex++] = data.filenames[data.filenr - 1];\n        }\n      }\n\n      if ( data.isAddingRowNumber ) {\n        outputRowData[outputIndex++] = new Long( data.rowNumber++ );\n      }\n\n      incrementLinesInput();\n      return outputRowData;\n    } catch ( Exception e ) {\n      throw new KettleFileException( \"Exception reading line using NIO\", e );\n    }\n  }\n\n  @Override\n  public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (S3CsvInputMeta) smi;\n    data = (S3CsvInputData) sdi;\n\n    if ( super.init( smi, sdi ) ) {\n\n      data.preferredBufferSize = 500000; // Fixed size\n\n      try {\n        //Get the specified bucket\n        String bucketname = environmentSubstitute( meta.getBucket() );\n        data.s3Client = meta.getS3Client( this );\n        data.s3bucket = new S3ObjectsProvider( data.s3Client ).getBucket( bucketname );\n        if ( data.s3bucket == null ) {","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/s3csvinput/core/src/main/java/org/pentaho/di/trans/steps/s3csvinput/S3CsvInput.java#L504-L540","documentation":"readOneRow reads and parses one CSV line via Kettle's NIO text-file reader from the S3 object stream. Any exception during reading/parsing (I/O failure, malformed encoding, conversion error) is wrapped in a KettleFileException with the literal message 'Exception reading line using NIO'.","triggerScenarios":"The S3 object stream errors mid-read (connection reset, stream closed), the byte/charset conversion fails, or field parsing throws while processing row content.","commonSituations":"S3 connection dropped during long reads of large files; file contains characters incompatible with the configured encoding; delimiter/enclosure settings causing parse failures; stream already closed by an earlier closeFile call.","solutions":["Inspect the KettleFileException cause for the root I/O or parse error","Re-check S3 connectivity / increase HTTP client timeouts for large files","Verify the file encoding setting matches the actual file charset","Validate delimiter, enclosure and escape settings against the file content","Retry the transformation if the cause is a transient network failure"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if ( data.s3ObjectInputStream == null ) throw new IllegalStateException( \"file not opened before read\" );","typeGuard":null,"tryCatchPattern":"try {\n  RowDataAndResult row = readOneRow();\n} catch ( KettleFileException e ) {\n  Throwable cause = e.getCause();\n  if ( cause instanceof IOException && isTransient( cause ) ) retryOrReopenFile();\n  else throw e;\n}","preventionTips":["Match file encoding setting to actual file charset","Validate delimiter/enclosure settings against a sample of the file","Increase HTTP client timeouts for large S3 objects","Ensure closeFile is not called while rows are still being read"],"tags":["s3","csv","io","nio","parsing"],"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"}