{"record":{"id":"8d6014de9035aaa2","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getshortfilename-throw-an-error-e-tostring","errorCode":null,"errorMessage":"The function call getShortFilename throw an error :  + e.toString()","messagePattern":"The function call getShortFilename throw an error :  \\+ e\\.toString\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2233,"sourceCode":"        if ( ArgList[0].equals( null ) ) {\n          return null;\n        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );\n          String Filename = null;\n          if ( file.exists() ) {\n            Filename = file.getName().getBaseName();\n\n          } else {\n            throw new RuntimeException( \"file [\" + ArgList[0] + \"] can not be found!\" );\n          }\n\n          return Filename;\n        } catch ( IOException e ) {\n          throw new RuntimeException( \"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 new RuntimeException( \"The function call getShortFilename is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e.toString() );\n    }\n  }\n","sourceCodeStart":2215,"sourceCodeEnd":2251,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2215-L2251","documentation":"This is the IOException handler of ScriptAddedFunctions.getShortFilename(): failures resolving or inspecting the VFS FileObject (KettleVFS.getFileObject, file.exists(), getName()) are re-thrown as RuntimeException with the message 'The function call getShortFilename throw an error : ' plus e.toString(). It indicates an I/O or transport problem rather than a simple 'file missing' condition.","triggerScenarios":"Calling getShortFilename(path) when the VFS layer throws IOException: unreachable SFTP/HTTP host, invalid VFS URI, network failure mid-call, or permission/IO errors reading the file's metadata.","commonSituations":"Remote files over sftp/webdav whose server is down or credentials expired; paths with unescaped spaces/special characters producing malformed URIs; transient network drops during large batch transformations.","solutions":["Inspect the appended e.toString() for the concrete IOException (unknown host, auth failure, malformed URI) and fix that cause.","Validate/encode the VFS URL (escape spaces and special chars) before calling.","Check remote connectivity and credentials; add a retry step for transient network errors.","Catch the RuntimeException in the JavaScript step to log and skip bad rows.","Fall back to computing the short name locally (substring after last '/' or '\\\\') when only the name is needed and the file cannot be inspected."],"exampleFix":"// before\nvar name = getShortFilename( \"/data/my file.txt\" ); // unescaped space -> IOException\n// after\nvar name = getShortFilename( \"file:///data/my%20file.txt\" );","handlingStrategy":"try-catch","validationCode":"// sanity-check the path/URL before the call\nif ( typeof p === \"string\" && p.length > 0 && p.indexOf(\" \") < 0 ) { name = getShortFilename(p); }","typeGuard":"function isPlainPath(v) { return typeof v === \"string\" && /^[A-Za-z0-9_\\-.:\\/\\\\]+$/.test(v); }","tryCatchPattern":"try { name = getShortFilename(p); } catch (e) { var m = String(e.message); if (m.indexOf(\"throw an error\") >= 0) { Logger.logError(\"getShortFilename IO: \" + m); } }","preventionTips":["Escape special characters in VFS URLs.","Verify remote host reachability and credentials before batch runs.","Implement retries for transient network errors.","Compute the base name locally when only the name is needed and inspection is not required."],"tags":["java","vfs","io","network","wrapped-exception"],"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"}