{"record":{"id":"6ee1c7226f860b19","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getlastmodifiedtime-throw-an-error","errorCode":null,"errorMessage":"The function call getLastModifiedTime throw an error : ","messagePattern":"The function call getLastModifiedTime 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":2452,"sourceCode":"          // Source file\n          file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );\n          String dateformat = Context.toString( ArgList[1] );\n          if ( isNull( dateformat ) ) {\n            dateformat = \"yyyy-MM-dd\";\n          }\n          String lastmodifiedtime = null;\n          if ( file.exists() ) {\n            java.util.Date lastmodifiedtimedate = new java.util.Date( file.getContent().getLastModifiedTime() );\n            java.text.DateFormat dateFormat = new SimpleDateFormat( dateformat );\n            lastmodifiedtime = dateFormat.format( lastmodifiedtimedate );\n\n          } else {\n            Context.reportRuntimeError( \"file [\" + Context.toString( ArgList[0] ) + \"] can not be found!\" );\n          }\n\n          return lastmodifiedtime;\n        } catch ( IOException e ) {\n          throw Context.reportRuntimeError( \"The function call getLastModifiedTime throw an error : \"\n            + 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 getLastModifiedTime is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n  }","sourceCodeStart":2434,"sourceCodeEnd":2470,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2434-L2470","documentation":"getLastModifiedTime() reads the last-modified timestamp of the file named by its single argument through KettleVFS. When a java.io.IOException occurs while resolving the VFS file object or reading its metadata, the function rethrows it as a JavaScript runtime error: 'The function call getLastModifiedTime throw an error : ' followed by the exception text — an I/O-layer failure, not an argument-validation failure.","triggerScenarios":"IOException from KettleVFS.getFileObject(path) or metadata reads on the FileObject — invalid/unreachable VFS URI, unsupported scheme/provider, network filesystem down, permission or resolution I/O errors.","commonSituations":"SFTP/S3/HDFS endpoints unreachable, expired credentials, unescaped characters breaking URI parsing, missing provider jars for the scheme, stale mounts in long-running transforms.","solutions":["Confirm the path is a valid, fully-qualified VFS URI","Verify filesystem reachability and valid credentials","Check existence first with isFile()/isFolder() to isolate resolution failures","Align/upgrade commons-vfs and provider dependencies"],"exampleFix":"// before\nvar t = getLastModifiedTime('hdfs:/namenode/data/f.csv'); // missing double slash\n// after\nvar t = getLastModifiedTime('hdfs://namenode/data/f.csv');","handlingStrategy":"try-catch","validationCode":"var f = isFile(path); // confirm the file resolves before reading metadata","typeGuard":"function isAbsoluteVfsPath(v) { return typeof v === 'string' && /^[a-z]+:\\/\\//.test(v); }","tryCatchPattern":"try { var t = getLastModifiedTime(path); } catch (e) {\n  // 'getLastModifiedTime throw an error : <IOException>'\n  t = null; }","preventionTips":["Use correct scheme syntax (hdfs://, sftp://, file://)","Validate connectivity/credentials to remote stores","Check file existence before metadata calls","Refresh stale network mounts; keep provider jars updated"],"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"}