{"record":{"id":"20ee1701526247b1","repo":"apache/dolphinscheduler","slug":"the-file-path-filepath-not-exists","errorCode":null,"errorMessage":"The file path: + filePath + not exists","messagePattern":"The file path: \\+ filePath \\+ not exists","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java","lineNumber":76,"sourceCode":"\n    public static byte[] getFileContentBytesFromRemote(String filePath) {\n        RemoteLogUtils.getRemoteLog(filePath);\n        return getFileContentBytesFromLocal(filePath);\n    }\n\n    public static List<String> readPartFileContentFromLocal(String filePath,\n                                                            int skipLine,\n                                                            int limit) {\n        File file = new File(filePath);\n        if (file.exists() && file.isFile()) {\n            try (Stream<String> stream = Files.lines(Paths.get(filePath))) {\n                return stream.skip(skipLine).limit(limit).collect(Collectors.toList());\n            } catch (IOException e) {\n                log.error(\"read file error\", e);\n                throw new RuntimeException(String.format(\"Read file: %s error\", filePath), e);\n            }\n        } else {\n            throw new RuntimeException(\"The file path: \" + filePath + \" not exists\");\n        }\n    }\n\n    public static List<String> readPartFileContentFromRemote(String filePath,\n                                                             int skipLine,\n                                                             int limit) {\n        RemoteLogUtils.getRemoteLog(filePath);\n        return readPartFileContentFromLocal(filePath, skipLine, limit);\n    }\n\n    public static String rollViewLogLines(List<String> lines) {\n        StringBuilder builder = new StringBuilder();\n        final int MaxResponseLogSize = 65535;\n        int totalLogByteSize = 0;\n        for (String line : lines) {\n            // If a single line of log is exceed max response size, cut off the line\n            final int lineByteSize = line.getBytes(StandardCharsets.UTF_8).length;\n            if (lineByteSize >= MaxResponseLogSize) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LogUtils.java#L58-L94","documentation":"In LogUtils.readPartFileContentFromLocal, if the given path does not exist or is not a regular file, the method immediately throws RuntimeException('The file path: <path> not exists'). This is a pre-check failure before any I/O is attempted, so no cause exception is attached.","triggerScenarios":"Calling readPartFileContentFromLocal(filePath, skipLine, limit) when new File(filePath).exists() is false or the path is a directory/symlink target that vanished — typically a log file that was deleted, rotated, or whose path was constructed incorrectly.","commonSituations":"Viewing logs of an old task instance after log cleanup/retention deleted the files; wrong master/worker host querying a log that lives on another machine; wrong task instance id producing a bad path; container restarts that lost ephemeral log volumes.","solutions":["Verify the file exists with Files.exists/Files.isRegularFile before calling, and return a friendly 'log expired' message to the user","Check that the path points to the correct host — read logs through the remote variant (readPartFileContentFromRemote) on the worker that owns the file","Reconstruct the path from the correct task instance/app id rather than a cached or stale value","Extend log retention or archive logs before cleanup if they must remain viewable","If the file may appear shortly (async writer), retry after a short delay"],"exampleFix":"// before\nList<String> lines = LogUtils.readPartFileContentFromLocal(path, 0, 100);\n// after\nFile f = new File(path);\nif (!f.exists() || !f.isFile()) {\n    log.warn(\"Log file not found: {}\", path);\n    return Collections.emptyList();\n}\nList<String> lines = LogUtils.readPartFileContentFromLocal(path, 0, 100);","handlingStrategy":"validation","validationCode":"boolean logFileAvailable(String path) {\n  File f = new File(path);\n  return f.exists() && f.isFile();\n}","typeGuard":null,"tryCatchPattern":"try {\n  List<String> lines = LogUtils.readPartFileContentFromLocal(filePath, skip, limit);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"not exists\")) {\n    log.info(\"Log file already cleaned up: {}\", filePath);\n    lines = Collections.emptyList();\n  } else { throw e; }\n}","preventionTips":["Always check Files.exists/Files.isRegularFile before reading","Query logs on the host that owns the file (use the remote variant) instead of local paths across nodes","Configure log retention longer than the UI's log-view window","Derive log paths from the current task instance metadata, not stale cached values"],"tags":["file-not-found","logs","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}