{"record":{"id":"d5e505ed6c8475e1","repo":"pentaho/pentaho-kettle","slug":"changefileencoding-error-targetfileisempty","errorCode":"ChangeFileEncoding.Error.TargetFileIsEmpty","errorMessage":"ChangeFileEncoding.Error.TargetFileIsEmpty","messagePattern":"ChangeFileEncoding\\.Error\\.TargetFileIsEmpty","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java","lineNumber":131,"sourceCode":"      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\n      // Check if source file is a file\n      if ( data.sourceFile.getType() != FileType.FILE ) {\n        throw new KettleException(\n            BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.SourceFileNotAFile\", sourceFilename ) );\n      }\n\n      // create directory only if not exists","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java#L113-L149","documentation":"The Change File Encoding step wraps a KettleException because the target filename field read from the output row is empty. The step refuses to proceed when it cannot determine which file to write the re-encoded content to. The message includes the configured target filename field name to help locate the misconfiguration.","triggerScenarios":"In processRow, when meta.getDynamicFilenameField() is set, the target filename is read from the output row via data.inputRowMeta.getString(outputRow, data.indexOfTargetFileename); if Utils.isEmpty(targetFilename) is true, this error is thrown.","commonSituations":"The 'Target filename field' in the step dialog points to a field that is not populated by the previous step; the field exists but contains null or empty string; a typo in the dynamic filename field mapping means a different (empty) column is read.","solutions":["Verify the 'Target filename field' setting in the Change File Encoding step dialog matches a real, populated input field.","Add or fix the upstream step that produces the target filename field so it emits a non-empty absolute path.","Use a 'Value Mapper' or 'If field value is null' step before this one to replace null/empty filenames with a valid default.","If the target path is static, disable the dynamic filename option and enter the filename directly instead of a field name."],"exampleFix":"// before: reading an empty dynamic field\nString targetFilename = data.inputRowMeta.getString( outputRow, data.indexOfTargetFileename );\n// fix upstream: ensure the field is populated\n// in a 'Get variables' / 'User Defined Java Expression' step:\n//   target_file = ${Internal.Transformation.Filename.Directory} + \"/output.txt\"","handlingStrategy":"validation","validationCode":"// Kettle: validate before the step\nif ( row.getString( targetFilenameField, \"\" ).trim().isEmpty() ) {\n  throw new KettleException( \"target filename field is empty for row: \" + row );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always verify the dynamic filename field exists in the incoming row layout before enabling dynamic mode.","Add a null/empty guard step upstream when filenames are computed dynamically.","Use fixed filenames where possible to avoid field-population surprises."],"tags":["etl","kettle","file-encoding","validation"],"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"}