PG1204 opened a new pull request, #9306:
URL: https://github.com/apache/texera/pull/9306

   ### What changes were proposed in this PR?
   
   `_read_binary_value` turned an image or audio cell into bytes whatever its 
size: the whole value was stripped, checked for HTML and base64-decoded, once 
per row. A remote fetch of the same payload already stops at 
`MAX_REMOTE_FETCH_BYTES` (25 MiB), so the same data was refused over HTTP and 
accepted from a column.
   
   The generated Python now checks a cell's size first, against the same 
constant:
   
   - a `bytes` cell is checked before it is returned
   - any other value is checked right after `str(value)`, before `strip()`, the 
HTML check, the decodes and the remote fetch
   
   An oversized value raises `ValueError("Column value exceeds the 26214400 
character limit.")` (or `byte limit` for a `bytes` cell). Both callers already 
turn an exception into a per-row `Image data error` / `Audio data error`, so 
one oversized cell fails its own row and the run continues.
   
   Worth knowing: for a string the cap counts characters, so a base64 cell, 
which is 4 characters per 3 bytes, holds at most about 18.75 MiB of decoded 
data. Images are compressed to about 33 KB before they are sent anyway.
   
   ### Any related issues?
   
   Closes #8962
   
   ### How was this PR tested?
   
   The tests were written first.
   
   - `HuggingFaceCodegenBaseSpec`: the size check comes before `strip()`, 
`_looks_like_html`, `base64.b64decode` and `_fetch_remote_url`, and the `bytes` 
branch is checked before it returns.
   - New `HuggingFaceBinaryValueBehaviorSpec`: it runs the generated 
`_read_binary_value` under a real interpreter, with the parsing helpers 
replaced by recorders. An oversized string or `bytes` value raises, and nothing 
parses it first. Values exactly at the limit are still parsed and returned. 
Before the change, a 26,214,401-character cell was checked for HTML and 
base64-decoded, and came back as 26 MB of bytes.
   
   All three new assertions failed on `main` and pass with the change. 
Reverting the change makes exactly those three fail again. The Hugging Face 
suites pass (173 tests), the generated Python of all 117 operators compiles, 
and scalafmt and scalafix are clean.
   
   The behaviour spec has its own small probe (`hf_binary_value_probe.py`) 
rather than extending `HuggingFaceParseBehaviorSpec`, because #9102 has that 
spec open. It uses the same interpreter lookup and method-lifting approach, so 
the two could share a helper once #9102 lands.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Yes, this PR was co-authored with Claude in compliance with ASF policy.
   


-- 
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