{"record":{"id":"e6741c495fe8335f","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getshortfilename-throw-an-error","errorCode":null,"errorMessage":"The function call getShortFilename throw an error : ","messagePattern":"The function call getShortFilename throw an error : ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2322,"sourceCode":"        if ( ArgList[0].equals( null ) ) {\n          return null;\n        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );\n          String Filename = null;\n          if ( file.exists() ) {\n            Filename = file.getName().getBaseName().toString();\n\n          } else {\n            Context.reportRuntimeError( \"file [\" + Context.toString( ArgList[0] ) + \"] can not be found!\" );\n          }\n\n          return Filename;\n        } catch ( IOException e ) {\n          throw Context.reportRuntimeError( \"The function call getShortFilename throw an error : \" + e.toString() );\n        } finally {\n          if ( file != null ) {\n            try {\n              file.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n        }\n\n      } else {\n        throw Context.reportRuntimeError( \"The function call getShortFilename is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n  }\n","sourceCodeStart":2304,"sourceCodeEnd":2340,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2304-L2340","documentation":"getShortFilename() returns the base name (filename without directory) of the file identified by its single argument, using KettleVFS. If a java.io.IOException is thrown while resolving the VFS file object or reading its name, the function converts it to a JavaScript runtime error: 'The function call getShortFilename throw an error : ' followed by the exception text.","triggerScenarios":"KettleVFS.getFileObject() or file.getName() throwing IOException — malformed VFS URI, unsupported scheme/provider, unreachable remote filesystem, or I/O failure during resolution/close.","commonSituations":"Remote SFTP/S3 paths when the network is down, paths with unescaped spaces or special characters, missing VFS provider for the URI scheme, VFS library version mismatch.","solutions":["Validate/normalize the path as a proper VFS URI before calling","Confirm the filesystem is reachable and the scheme is supported","Test the path with file.exists()-style checks (isFile) first","Update commons-vfs and provider dependencies if the scheme is valid"],"exampleFix":"// before\nvar name = getShortFilename('sftps://host/dir/file.txt'); // wrong scheme\n// after\nvar name = getShortFilename('sftp://host/dir/file.txt');","handlingStrategy":"try-catch","validationCode":"var f = isFile(path); // existence/I-O errors surface here first","typeGuard":"function isValidPath(v) { return typeof v === 'string' && v.length > 0 && !/\\s{2,}/.test(v); }","tryCatchPattern":"try { var n = getShortFilename(path); } catch (e) {\n  n = null; // IOException from VFS — handle unavailable file\n}","preventionTips":["Validate URI format before VFS calls","Test remote endpoints reachability at job start","Escape path special characters","Pin compatible commons-vfs/jsch versions"],"tags":["io","vfs","filesystem"],"backgroundTag":"file-read-failed","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"}