JiriOndrusek opened a new issue, #3121:
URL: https://github.com/apache/camel-kamelets/issues/3121
Follow-up to #3086. `tika-extract-text-action` and `docling-convert-action`
(4.23.0, same on main) reject documents bigger than `maxDocumentSize`, but only
after reading them completely. The limit does not protect memory. (Based on the
v4.23.0 Kamelets and Camel 4.23.0 sources, not benchmarked.)
The check is `${length()} > {{maxDocumentSize}}`, run before the parse:
- To count the size, `length()` reads a file or stream to the end. Only
`byte[]` and cached streams skip this. A 10 GB file is read in full before it
is rejected.
- `length()` consumes an uncached stream, so both Kamelets first convert the
body to `byte[]`. The whole payload is in memory before the limit applies.
- The size is an `int`. From 2 GiB it overflows and can pass the check.
- The error message evaluates `${length()}` again, so a rejected file is
read twice.
Proposal, in both actions:
- Files: when the `CamelFileLength` header is set (file consumer), use it.
No read needed.
- Streams: read at most `maxDocumentSize + 1` bytes. If more than
`maxDocumentSize` come back, reject. Otherwise the bytes read are the document.
_Generated with [Claude Code](https://claude.com/claude-code) on behalf of
@JiriOndrusek_
--
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]