{"record":{"id":"7664eced21c5bc42","repo":"apache/seatunnel","slug":"failed-to-resolve-log-file-path-error","errorCode":null,"errorMessage":"Failed to resolve log file path: {}, error: {}","messagePattern":"Failed to resolve log file path: (.+?), error: (.+?)","errorType":"console","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/LogBaseServlet.java","lineNumber":75,"sourceCode":"        String logFilePath = new File(logPath, logName).getPath();\n        try {\n            String canonicalLogDir = new File(logPath).getCanonicalPath();\n            String canonicalFilePath = new File(logFilePath).getCanonicalPath();\n            if (!canonicalFilePath.startsWith(canonicalLogDir + File.separator)\n                    && !canonicalFilePath.equals(canonicalLogDir)) {\n                resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);\n                log.warn(\n                        \"Path traversal attempt blocked - Requested: {}, Resolved: {}, LogDir: {}\",\n                        logName,\n                        canonicalFilePath,\n                        canonicalLogDir);\n                return;\n            }\n            String logContent = FileUtils.readFileToStr(new File(canonicalFilePath).toPath());\n            write(resp, logContent);\n        } catch (IOException e) {\n            resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);\n            log.warn(\"Failed to resolve log file path: {}, error: {}\", logFilePath, e.getMessage());\n        } catch (SeaTunnelRuntimeException e) {\n            resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);\n            log.warn(String.format(\"Log file content is empty, get log path : %s\", logFilePath));\n        }\n    }\n}\n","sourceCodeStart":57,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/LogBaseServlet.java#L57-L82","documentation":"LogBaseServlet.prepareLogResponse failed to read the requested log file — the catch (IOException) around path resolution/read sets HTTP 400 and logs this warning with the requested logFilePath and the error message. It means the REST log API could not serve the file (bad path, unreadable, or file gone).","triggerScenarios":"GET on the REST log endpoint with a logFilePath that cannot be canonicalized or read: nonexistent file, directory instead of file, permission error, or path outside the log dir rejected by the path check.","commonSituations":"Querying logs from a node where the file does not exist (wrong node/worker); requesting rotated/deleted log files; invalid or malicious path parameters; running with a different user lacking read permission on the log directory.","solutions":["Verify the requested logFilePath exists on the target node and the filename is correct (list via the log listing endpoint first).","Check the process user has read permission on the log file and its directory.","Confirm you are querying the correct cluster node — worker logs live on their host, not the master.","Check that log rotation hasn't removed the file; request the current active log file."],"exampleFix":"// before\ncurl 'http://host:8080/logs/missing-node.log'\n// after: list valid files first\ncurl 'http://host:8080/logs/'  # then request a file from the returned list","handlingStrategy":"validation","validationCode":"// before requesting a log file\nconst files = await fetch('/logs/').then(r => r.json());\nconst valid = files.some(f => f.name === requestedLogName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List available log files via the REST API before fetching one","Query the node that actually hosts the log (workers vs master)","Check log rotation retention on the target node"],"tags":["rest","logging","file-io","servlet"],"backgroundTag":"file-read-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}