{"record":{"id":"c173139d26402e26","repo":"pentaho/pentaho-kettle","slug":"changefileencoding-error-sourcefilenotexists","errorCode":"ChangeFileEncoding.Error.SourceFileNotExists","errorMessage":"ChangeFileEncoding.Error.SourceFileNotExists","messagePattern":"ChangeFileEncoding\\.Error\\.SourceFileNotExists","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java","lineNumber":139,"sourceCode":"      // 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\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      }","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java#L121-L157","documentation":"The Change File Encoding step resolves the source filename through KettleVFS and checks data.sourceFile.exists(). If the file does not exist on the filesystem/VFS, it throws this KettleException with the source path in the message. The step cannot re-encode a file it cannot open.","triggerScenarios":"In processRow: data.sourceFile = KettleVFS.getInstance(...).getFileObject(sourceFilename); then if (!data.sourceFile.exists()) throw — the resolved source path does not exist at run time.","commonSituations":"Typo in the source filename field value; the file was deleted or moved between pipeline planning and execution; relative path resolved against an unexpected working directory; wrong case sensitivity on Linux; a variable like ${FILE} is unset so the path is literal '/${FILE}'.","solutions":["Check the exact path in the error message and confirm the file exists: ls '<path from message>'.","Fix the source filename field value or the dynamic field so it points to an existing file.","Convert to an absolute path or set the correct working directory / Kettle variables.","Add an upstream 'Check if file exists' step or an ETL Metadata Injection guard to fail fast with a clearer message."],"exampleFix":"// before: path built from an unset variable\nString sourceFilename = \"${INPUT_DIR}/data.txt\"; // resolves literally\n// after: resolve via VariableSpace\nString sourceFilename = getTransMeta().environmentSubstitute( \"${INPUT_DIR}\" ) + \"/data.txt\";","handlingStrategy":"validation","validationCode":"import java.io.File;\n// Java caller-side check before running the transformation\nFile src = new File( resolvedSourcePath );\nif ( !src.exists() ) {\n  throw new IllegalStateException( \"Source file missing: \" + src.getAbsolutePath() );\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute( null );\n} catch ( KettleException e ) {\n  if ( e.getMessage().contains( \"SourceFileNotExists\" ) ) {\n    log.warn( \"Source file missing, skipping: {}\", e.getMessage() );\n  } else { throw e; }\n}","preventionTips":["Use environmentSubstitute for variables in paths and verify the substituted value resolves.","Prefer absolute paths over relative ones in transformations.","Add a 'Check if file exists' job entry before the transformation."],"tags":["etl","kettle","file-not-found","vfs"],"backgroundTag":"file-not-found","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"}