Skip to content

fix(workflow-operator): route image chat extraction through the type-checked helper - #9102

Open
PG1204 wants to merge 4 commits into
apache:mainfrom
PG1204:fix/hf-image-chat-degrade
Open

PG1204 wants to merge 4 commits into
apache:mainfrom
PG1204:fix/hf-image-chat-degrade

Conversation

@PG1204

@PG1204 PG1204 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

ImageTaskCodegen.parsePython decoded a chat provider's reply at four sites by indexing into choices[0] and calling .get on the result. A choices value that is not a list of dictionaries ([null], "bad", [42]), or whose first choice has a non-dict message ([{"message": null}]), therefore raised AttributeError, which _parse_response's except (KeyError, IndexError, TypeError) does not catch. The row's cell ended up reading "Request failed" instead of the body.

All four now delegate to _chat_message_content, the shared type-checked helper added in #8617, which validates every level and returns None when the body is not a readable chat response. Each branch then falls back to its native shape or to json.dumps(body), as before.

This completes the work #8617 started: that PR deliberately left these four sites out to keep its diff to the files under review.

Any related issues?

Closes #8634

How was this PR tested?

Written test-first: the five image tasks were added to HuggingFaceParseBehaviorSpec, which executes the generated parser against 12 malformed response shapes. They fail against the current code with exactly the reported error — task=visual-question-answering body={"choices": [null]} raising AttributeError — and pass with the change.

166 tests pass across the Hugging Face suites, and PythonCodeRawInvalidTextSpec py-compiles the generated Python for all 117 operators.

One shape was moved out of the shared malformed list: [{"generated_text": "x"}] is a success path for the image codegens and an unrecognised shape for the text ones, so it is now asserted per task instead.

Was this PR authored or co-authored using generative AI tooling?

Yes, this PR was co-authored with Claude in compliance with ASF policy.

@Yicong-Huang Yicong-Huang added the release/v1.3 back porting to release/v1.3 label Oct 23, 2026
@github-actions
github-actions Bot requested a review from mengw15 October 23, 2026 10:38
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.
⚠️ release/v1.2 Not labeled automatically — none of the files this PR modifies exist on this branch (common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/ImageTaskCodegen.scala, common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/codegen/HuggingFaceParseBehaviorSpec.scala, common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/codegen/ImageTaskCodegenSpec.scala). The fix may target code that isn't on this release, or the files were moved/renamed after the branch was cut. Please check and add release/v1.2 by hand if this fix should be backported here — its release manager then has to approve before this PR can merge.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 7 worse · ⚪ 8 noise (<±5%) · 0 without baseline

Compared against main 8420565 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 385 0.235 26,317/34,602/34,602 us 🔴 +39.7% / 🔴 +143.9%
🔴 bs=100 sw=10 sl=64 956 0.583 102,739/149,072/149,072 us 🔴 +22.5% / 🔴 +54.7%
⚪ bs=1000 sw=10 sl=64 1,121 0.684 888,305/998,918/998,918 us ⚪ within ±5% / 🔴 +8.8%
Baseline details

Latest main 8420565 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 385 tuples/sec 476 tuples/sec 880.16 tuples/sec -19.1% -56.3%
bs=10 sw=10 sl=64 MB/s 0.235 MB/s 0.291 MB/s 0.537 MB/s -19.2% -56.3%
bs=10 sw=10 sl=64 p50 26,317 us 18,842 us 11,544 us +39.7% +128.0%
bs=10 sw=10 sl=64 p95 34,602 us 32,051 us 14,186 us +8.0% +143.9%
bs=10 sw=10 sl=64 p99 34,602 us 32,051 us 17,122 us +8.0% +102.1%
bs=100 sw=10 sl=64 throughput 956 tuples/sec 997 tuples/sec 1,151 tuples/sec -4.1% -17.0%
bs=100 sw=10 sl=64 MB/s 0.583 MB/s 0.609 MB/s 0.703 MB/s -4.3% -17.0%
bs=100 sw=10 sl=64 p50 102,739 us 101,019 us 89,900 us +1.7% +14.3%
bs=100 sw=10 sl=64 p95 149,072 us 121,655 us 96,346 us +22.5% +54.7%
bs=100 sw=10 sl=64 p99 149,072 us 121,655 us 110,344 us +22.5% +35.1%
bs=1000 sw=10 sl=64 throughput 1,121 tuples/sec 1,148 tuples/sec 1,189 tuples/sec -2.4% -5.7%
bs=1000 sw=10 sl=64 MB/s 0.684 MB/s 0.701 MB/s 0.726 MB/s -2.4% -5.8%
bs=1000 sw=10 sl=64 p50 888,305 us 862,062 us 873,675 us +3.0% +1.7%
bs=1000 sw=10 sl=64 p95 998,918 us 966,681 us 918,440 us +3.3% +8.8%
bs=1000 sw=10 sl=64 p99 998,918 us 966,681 us 953,075 us +3.3% +4.8%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,519.36,200,128000,385,0.235,26317.35,34601.68,34601.68
1,100,10,64,20,2092.41,2000,1280000,956,0.583,102738.96,149072.43,149072.43
2,1000,10,64,20,17835.48,20000,12800000,1121,0.684,888305.47,998918.46,998918.46

@codecov-commenter

codecov-commenter commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.81%. Comparing base (8420565) to head (b078dbd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9102   +/-   ##
=========================================
  Coverage     91.80%   91.81%           
- Complexity     5020     5021    +1     
=========================================
  Files          1277     1277           
  Lines         56385    56346   -39     
  Branches       7365     7359    -6     
=========================================
- Hits          51767    51734   -33     
+ Misses         2760     2757    -3     
+ Partials       1858     1855    -3     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø)
agent-service 99.53% <ø> (ø) Carriedforward from a302e9d
amber 85.79% <ø> (+0.01%) ⬆️
computing-unit-managing-service 64.05% <ø> (ø)
config-service 87.73% <ø> (ø)
file-service 82.31% <ø> (ø)
frontend 96.53% <ø> (-0.01%) ⬇️ Carriedforward from a302e9d
notebook-migration-service 83.77% <ø> (ø)
pyamber 98.50% <ø> (+0.06%) ⬆️ Carriedforward from a302e9d
workflow-compiling-service 78.30% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mengw15 mengw15 removed the release/v1.3 back porting to release/v1.3 label Nov 9, 2026
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 10, 2026
…before parsing it (apache#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 apache#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 apache#9102 has
that spec open. It uses the same interpreter lookup and method-lifting
approach, so the two could share a helper once apache#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]>
@PG1204

PG1204 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @xuang7

@github-actions
github-actions Bot requested a review from xuang7 November 10, 2026 18:12

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed chat responses show "Request failed" instead of the body for image tasks

4 participants