{"record":{"id":"af2c659e1ae0f67c","repo":"pentaho/pentaho-kettle","slug":"changefileencoding-error-sourcefileisempty","errorCode":"ChangeFileEncoding.Error.SourceFileIsEmpty","errorMessage":"ChangeFileEncoding.Error.SourceFileIsEmpty","messagePattern":"ChangeFileEncoding\\.Error\\.SourceFileIsEmpty","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java","lineNumber":124,"sourceCode":"\n      // if(Utils.isEmpty(data.sourceEncoding)) {\n      // throw new KettleException(BaseMessages.getString(PKG, \"ChangeFileEncoding.Exception.SourceEncodingEmpty\"));\n      // }\n      // Check target encoding\n      data.targetEncoding = environmentSubstitute( meta.getTargetEncoding() );\n\n      if ( Utils.isEmpty( data.targetEncoding ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Exception.TargetEncodingEmpty\" ) );\n      }\n\n      // End If first\n    }\n\n    try {\n      // get source filename\n      String sourceFilename = data.inputRowMeta.getString( outputRow, data.indexOfFileename );\n      if ( Utils.isEmpty( sourceFilename ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.SourceFileIsEmpty\",\n          meta.getDynamicFilenameField() ) );\n      }\n\n      // get target filename\n      String targetFilename = data.inputRowMeta.getString( outputRow, data.indexOfTargetFileename );\n      if ( Utils.isEmpty( targetFilename ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.TargetFileIsEmpty\",\n          meta.getTargetFilenameField() ) );\n      }\n\n      data.sourceFile = KettleVFS.getInstance( getTransMeta().getBowl() ).getFileObject( sourceFilename );\n\n      // Check if source file exists\n      if ( !data.sourceFile.exists() ) {\n        throw new KettleException(\n            BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.SourceFileNotExists\", sourceFilename ) );\n      }\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java#L106-L142","documentation":"For each row the step reads the source filename from the configured field; if the value is null or empty it cannot open a file to convert and throws this localized KettleException naming the offending field.","triggerScenarios":"processRow per row: data.inputRowMeta.getString(outputRow, data.indexOfFileename) returns empty/null and Utils.isEmpty(sourceFilename) is true — i.e. an incoming row has no value in the filename field.","commonSituations":"Upstream 'Get File Names' matched no files so path fields are empty; rows generated from data (e.g. a Table Input) with null path columns; optional rows flowing through where a filename was never set; earlier steps overwriting the field with an empty string.","solutions":["Filter out rows with empty filename before this step (Filter rows: filename IS NOT NULL AND filename <> '').","Fix the upstream step so it populates the filename field for every row (check file-list/table query logic).","Provide a default path or use 'If field value is null' to set a value.","Validate with a preview/data grid which rows carry empty filenames."],"exampleFix":"// before: passing rows straight through with null paths\nTable Input -> Change File Encoding\n// after\nTable Input -> Filter rows (filename IS NOT NULL AND filename != '') -> Change File Encoding","handlingStrategy":"validation","validationCode":"// before the step, in a Filter rows / UDJC guard:\nif (getFieldValue(r, \"source_file\") == null || getFieldValue(r, \"source_file\").toString().isEmpty()) {\n  return false; // divert row to an error/log stream\n}","typeGuard":null,"tryCatchPattern":"try {\n  // execute transformation\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"SourceFileIsEmpty\")) {\n    // route empty-filename rows through a Filter rows step and re-run\n  } else { throw e; }\n}","preventionTips":["Filter null/empty filenames before this step","Fix upstream file-listing or table queries that produce empty paths","Preview data to spot rows with missing paths"],"tags":["kettle","data-quality","null-value","row-stream"],"backgroundTag":"empty-required-field","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"}