{"record":{"id":"643799881de82d38","repo":"pentaho/pentaho-kettle","slug":"the-function-call-copyfileis-not-valid","errorCode":null,"errorMessage":"The function call copyFileis not valid.","messagePattern":"The function call copyFileis not valid\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2075,"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 new RuntimeException( \"The function call copyFileis not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e.toString() );\n    }\n  }\n\n  public static double getFileSize( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object 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( bowl ).getFileObject( (String) ArgList[0] );","sourceCodeStart":2057,"sourceCodeEnd":2093,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2057-L2093","documentation":"Thrown by ScriptAddedFunctions.copyFile when the JavaScript call to copyFile does not receive exactly the arguments the function requires. The function copies a file via KettleVFS but first validates the argument list; a wrong argument count makes the call 'not valid' and it aborts with this RuntimeException.","triggerScenarios":"Calling copyFile(args, context) from a JavaScript/UDJE step with an ArgList whose length does not match the expected count (source path and destination path), e.g. passing 0, 1, or 3+ arguments, or passing null ArgList.","commonSituations":"A typo in the JavaScript call (forgot the destination argument), refactored code that dropped a parameter, or dynamically built argument arrays that end up empty.","solutions":["Pass exactly two arguments: copyFile('/path/source.txt', '/path/dest.txt').","Check the JavaScript step code for a missing or extra comma/argument in the copyFile call.","Verify the argument array is built correctly if constructed programmatically before the call."],"exampleFix":"// before\n copyFile('/data/input.csv');\n// after\n copyFile('/data/input.csv', '/data/backup/input.csv');","handlingStrategy":"validation","validationCode":"// in the JS step, before calling\nif (srcPath != null && dstPath != null) {\n  copyFile(srcPath, dstPath);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass exactly two arguments (source, destination) to copyFile.","Keep the call signature in a small helper function to centralize the contract."],"tags":["kettle","javascript-step","argument-count","file-copy"],"backgroundTag":"missing-required-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"}