The GitHub Actions job "Required Checks" on texera.git/main has succeeded.
Run started by GitHub user github-merge-queue[bot] (triggered by 
github-merge-queue[bot]).

Head commit for run:
cfca8e1e5de816c4f0d3f0d97e2b8fe3276f9c34 / Prateek Ganigi 
<[email protected]>
fix(workflow-operator): cap a column value at the remote-fetch limit before 
parsing it (#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.

Co-authored-by: Xuan Gu <[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/42757121480

With regards,
GitHub Actions via GitBox

Reply via email to