{"record":{"id":"6bbcbb1d3fa3c509","repo":"pentaho/pentaho-kettle","slug":"the-function-call-copyfileis-not-valid-6bbcbb","errorCode":null,"errorMessage":"The function call copyFileis not valid.","messagePattern":"The function call copyFileis not valid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2164,"sourceCode":"        } finally {\n          if ( fileSource != null ) {\n            try {\n              fileSource.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n          if ( fileDestination != null ) {\n            try {\n              fileDestination.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n        }\n\n      } else {\n        throw Context.reportRuntimeError( \"The function call copyFileis not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n  }\n\n  public static double getFileSize( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    try {\n      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {\n        if ( ArgList[0].equals( null ) ) {\n          return 0;\n        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );","sourceCodeStart":2146,"sourceCodeEnd":2182,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2146-L2182","documentation":"copyFile() throws this (note the missing space, 'copyFileis') when it is called with an argument list that does not match the expected shape of two string path arguments. No copy is attempted. The malformed message is a known artifact of the source string in ScriptValuesAddedFunctions.","triggerScenarios":"Calling copyFile() with zero, one, or three-plus arguments, or with non-string arguments, in a JavaScript step.","commonSituations":"Forgetting the destination argument; passing field objects instead of .stringValue(); a null variable for the target path due to upstream data issues.","solutions":["Call copyFile with exactly two string arguments: copyFile(src, dst).","Convert Kettle fields with .stringValue() before passing.","Null-check both paths before the call.","Remember the same function also validates types at other branches; fix the call site, not the files."],"exampleFix":"// before\ncopyFile(sourceField.stringValue()); // missing destination\n// after\ncopyFile(sourceField.stringValue(), '/data/backup/' + sourceField.stringValue());","handlingStrategy":"validation","validationCode":"var s = srcField == null ? null : srcField.stringValue();\nvar d = dstField == null ? null : dstField.stringValue();\nif (s == null || d == null) { throw new Error('copyFile needs src and dst strings'); }\ncopyFile(s, d);","typeGuard":"function isNonEmptyString(v){ return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { copyFile(s, d); } catch (e) { Logger.logError('copyFile misuse: ' + e.message); }","preventionTips":["Always pass exactly two string arguments","Convert fields with .stringValue()","Null-check both paths","Note the message has a typo ('copyFileis'); it still means wrong argument shape"],"tags":["javascript","pdi","argument-count","file-copy"],"backgroundTag":"invalid-argument","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"}