SEZ9 opened a new issue, #12295:
URL: https://github.com/apache/seatunnel/issues/12295

   ### Search before asking
   
   - [X] I had searched in the 
[feature](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22Feature%22)
 and found no similar feature requirement.
   
   ### Description
   
   The REST log-content endpoints read the whole file into a `String` before 
writing the response, with no upper bound:
   
   ```java
   // LogBaseServlet#prepareLogResponse
   String logContent = FileUtils.readFileToStr(new 
File(canonicalFilePath).toPath());
   write(resp, logContent);
   ```
   
   ```java
   // FileUtils#readFileToStr
   byte[] bytes = Files.readAllBytes(path);
   return new String(bytes);
   ```
   
   `RestHttpGetCommandProcessor` carries an equivalent copy for REST v1.
   
   That means a single `GET /logs/<name>` on a long-running streaming job's log 
file materialises the entire file as a byte array **and** again as a `String` 
on the heap. A multi-gigabyte log — normal for a job that has been streaming 
for weeks — can push the node into a long GC pause or an `OutOfMemoryError`, 
taking down the whole engine node rather than just failing the request.
   
   The existing path-traversal guard in `prepareLogResponse` is intact; this is 
purely about response size.
   
   ### Usage Scenario
   
   An operator opens a job log through the Web UI or `curl`s the log endpoint 
on a node whose log files have grown large. Today that is enough to destabilise 
the node. There is no configuration knob to prevent it.
   
   Proposal: add `seatunnel.engine.http.log-response-max-size-mb` (default 
large enough to be a safety net rather than a behaviour change) and return the 
**tail** of the file when it exceeds the limit — the tail being the useful part 
when diagnosing a failure. The tail must be aligned to a line boundary, 
otherwise slicing at an arbitrary byte offset splits a multi-byte UTF-8 
character and the response starts with a replacement character.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to