{"record":{"id":"42fef398e64ca685","repo":"pentaho/pentaho-kettle","slug":"changefileencoding-error-sourcefilenotafile","errorCode":"ChangeFileEncoding.Error.SourceFileNotAFile","errorMessage":"ChangeFileEncoding.Error.SourceFileNotAFile","messagePattern":"ChangeFileEncoding\\.Error\\.SourceFileNotAFile","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java","lineNumber":145,"sourceCode":"\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\n      if ( !data.sourceFile.getParent().exists() ) {\n        if ( meta.isCreateParentFolder() ) {\n          data.sourceFile.getParent().createFolder();\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.ParentFolderNotExist\",\n            data.sourceFile.getParent().toString() ) );\n        }\n      }\n\n      // Change file encoding\n      changeEncoding( sourceFilename, targetFilename );\n\n      putRow( data.inputRowMeta, outputRow ); // copy row to output rowset(s);\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java#L127-L163","documentation":"After confirming the source path exists, the step checks that it is a regular file (VFS FileType.FILE). If the path is a directory, symlink to a folder, or other non-file resource, this KettleException is thrown with the path in the message. File encoding conversion only applies to regular files.","triggerScenarios":"In processRow: if (data.sourceFile.getType() != FileType.FILE) throw — the existing source path is a directory or other non-file VFS resource.","commonSituations":"The filename field accidentally contains a directory path; a glob was expected to expand but the literal directory name was passed; the user pointed the step at a mount point or a folder of files instead of a single file.","solutions":["Point the source filename at the individual file, not a directory.","Pre-process the directory with a 'Get File Names' step to enumerate files and loop over them.","Verify the path in the message is not a directory: test -d '<path>'."],"exampleFix":"// before\n// source filename field contains: /data/incoming\n// after: use Get File Names step to list files, pass /data/incoming/data.txt","handlingStrategy":"validation","validationCode":"import java.io.File;\nFile p = new File( resolvedSourcePath );\nif ( p.exists() && !p.isFile() ) {\n  throw new IllegalArgumentException( \"Path is not a regular file: \" + p );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never point single-file steps at directories; enumerate directories with 'Get File Names' first.","Log the resolved path before the step when filenames are dynamic."],"tags":["etl","kettle","file-type","vfs"],"backgroundTag":"incompatible-source-type","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"}