Skip to content

fix(workflow-operator, v1.3): degrade instead of raising on malformed chat responses - #9208

Merged
mengw15 merged 2 commits into
apache:release/v1.3from
PG1204:backport/8617-chat-degrade-v1.3
Oct 29, 2026
Merged

mengw15 merged 2 commits into
apache:release/v1.3from
PG1204:backport/8617-chat-degrade-v1.3

Conversation

@PG1204

@PG1204 PG1204 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Manual backport of #8617 to release/v1.3, replacing #8993, whose head branch lives in this repository and so could not be corrected by push.

The automated cherry-pick conflicted in one file, HuggingFaceCodegenBaseSpec.scala, and was committed with conflict markers. The cause is #8630, which is on main but not on this branch. #8630 appended three tests and a chatContentHelper helper to the end of that spec, and #8617 then appended its own test after them. Those three tests cover the candidate-labels feature that #8630 added, which this branch does not have, so they are left out. The spec here carries only the one test #8617 added.

Everything else applied cleanly. Against release/v1.3, each of the nine files carries exactly the change #8617 made on main.

Any related issues, documentation, discussions?

Backport of #8617. Originally linked #8486. Replaces #8993, which can be closed.

How was this PR tested?

The Hugging Face suites and PythonCodeRawInvalidTextSpec on this branch: 147 tests across 14 suites, all passing. That includes HuggingFaceParseBehaviorSpec, which runs the generated parser against malformed chat responses. The generated Python of all 117 operators compiles. scalafmtCheck and scalafix --check are clean for main and test.

With the three source files reverted to release/v1.3, 13 of those tests fail, all of them tests #8617 added or updated, so they exercise the fix on this branch.

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

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

…responses (apache#8617)

### What changes were proposed in this PR?

The text-generation and QA/ranking codegens read a chat provider's reply
by indexing straight into it:

    return body["choices"][0]["message"]["content"]

That assumes the response is a dict, that `choices` is non-empty, and
that the first choice carries `message.content`. When a provider returns
a 200 with anything else, the indexing raises, and since the parse step
runs once per row, a single malformed response aborts the entire run.
`TextGenCodegen` was the most exposed: it had no `isinstance` check
either, so even a plain list body raised.

All four extractions (one in `TextGenCodegen`, three in
`QaRankingCodegen`) now guard on a truthy `choices` and use `.get`
chaining, falling back to the raw JSON body. That is the same idiom
`ImageTaskCodegen` adopted in apache#7920, and it matches how the native
`hf-inference` shapes beside it already degrade via `body.get("answer",
json.dumps(body))`. A bad response now lands in the result column as raw
JSON instead of killing the run.

### Any related issues?

Closes apache#8486

### How was this PR tested?

145 tests pass in the Hugging Face suites,
`PythonCodeRawInvalidTextSpec` py-compiles the generated Python for all
117 operators, and `scalafmtCheck` and `scalafix --check` are clean.
Added a degradation test to `TextGenCodegenSpec` and
`QaRankingCodegenSpec`, and updated the assertions in
`HuggingFaceInferenceOpDescSpec` that pinned the old form.

The emitted Python was also run directly against the failing shapes,
comparing this branch with main across 33 task/response combinations: 16
of them raised before (`IndexError` on an empty `choices` list,
`KeyError` on a missing `message`/`content`, `TypeError` on a list body)
and none raise now. Well-formed chat responses and native `hf-inference`
responses parse identically to before.

### 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: Meng Wang <[email protected]>
@github-actions github-actions Bot added engine dependencies Pull requests that update a dependency file ddl-change Changes to the TexeraDB DDL pyamber frontend Changes related to the frontend GUI ci changes related to CI docs Changes related to documentations infra common platform Non-amber Scala service paths labels Oct 29, 2026
@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Oct 29, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 October 29, 2026 05:37
@github-actions

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 Change detected on this branch — label added; this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.

Auto-label run.

@PG1204
PG1204 changed the base branch from main to release/v1.3 October 29, 2026 05:38
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

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

  • Contributors with relevant context: @EmilySun621
    You can notify them by mentioning @EmilySun621 in a comment.

@mengw15 mengw15 removed release/v1.2 back porting to release/v1.2 release/v1.3 back porting to release/v1.3 labels Oct 29, 2026
@codecov-commenter

codecov-commenter commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.09%. Comparing base (f7394bf) to head (202ad03).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                Coverage Diff                 @@
##             release/v1.3    #9208      +/-   ##
==================================================
- Coverage           94.10%   94.09%   -0.02%     
+ Complexity           4809     4807       -2     
==================================================
  Files                1194     1194              
  Lines               48648    48616      -32     
  Branches             5868     5864       -4     
==================================================
- Hits                45780    45745      -35     
- Misses               1411     1413       +2     
- Partials             1457     1458       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø)
agent-service 99.32% <ø> (ø) Carriedforward from 457dd07
amber 90.10% <ø> (-0.01%) ⬇️
computing-unit-managing-service 73.67% <ø> (ø)
config-service 87.00% <ø> (ø)
file-service 87.75% <ø> (ø)
frontend 96.89% <ø> (+<0.01%) ⬆️ Carriedforward from 457dd07
notebook-migration-service 79.31% <ø> (ø)
pyamber 98.12% <ø> (-0.07%) ⬇️ Carriedforward from 457dd07
workflow-compiling-service 77.19% <ø> (ø)

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

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

Compared against main f7394bf 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 572 0.349 17,400/21,365/21,365 us 🔴 +17.0% / 🔴 +53.6%
🟢 bs=100 sw=10 sl=64 1,228 0.75 78,205/114,382/114,382 us 🟢 -8.7% / 🔴 +18.8%
🔴 bs=1000 sw=10 sl=64 1,450 0.885 682,366/782,393/782,393 us 🔴 +7.5% / 🟢 -22.3%
Baseline details

Latest main f7394bf from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 572 tuples/sec 598 tuples/sec 905.73 tuples/sec -4.3% -36.8%
bs=10 sw=10 sl=64 MB/s 0.349 MB/s 0.365 MB/s 0.553 MB/s -4.4% -36.9%
bs=10 sw=10 sl=64 p50 17,400 us 14,868 us 11,331 us +17.0% +53.6%
bs=10 sw=10 sl=64 p95 21,365 us 25,399 us 14,032 us -15.9% +52.3%
bs=10 sw=10 sl=64 p99 21,365 us 25,399 us 17,338 us -15.9% +23.2%
bs=100 sw=10 sl=64 throughput 1,228 tuples/sec 1,182 tuples/sec 1,205 tuples/sec +3.9% +1.9%
bs=100 sw=10 sl=64 MB/s 0.75 MB/s 0.721 MB/s 0.735 MB/s +4.0% +2.0%
bs=100 sw=10 sl=64 p50 78,205 us 84,167 us 89,237 us -7.1% -12.4%
bs=100 sw=10 sl=64 p95 114,382 us 125,246 us 96,280 us -8.7% +18.8%
bs=100 sw=10 sl=64 p99 114,382 us 125,246 us 111,344 us -8.7% +2.7%
bs=1000 sw=10 sl=64 throughput 1,450 tuples/sec 1,473 tuples/sec 1,239 tuples/sec -1.6% +17.1%
bs=1000 sw=10 sl=64 MB/s 0.885 MB/s 0.899 MB/s 0.756 MB/s -1.6% +17.1%
bs=1000 sw=10 sl=64 p50 682,366 us 679,397 us 877,826 us +0.4% -22.3%
bs=1000 sw=10 sl=64 p95 782,393 us 727,978 us 919,412 us +7.5% -14.9%
bs=1000 sw=10 sl=64 p99 782,393 us 727,978 us 963,000 us +7.5% -18.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,349.60,200,128000,572,0.349,17400.11,21364.97,21364.97
1,100,10,64,20,1628.08,2000,1280000,1228,0.750,78204.66,114381.63,114381.63
2,1000,10,64,20,13789.70,20000,12800000,1450,0.885,682365.88,782393.22,782393.22

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mengw15
mengw15 enabled auto-merge October 29, 2026 05:49
@github-actions github-actions Bot removed engine dependencies Pull requests that update a dependency file ddl-change Changes to the TexeraDB DDL labels Oct 29, 2026
@github-actions github-actions Bot removed pyamber frontend Changes related to the frontend GUI ci changes related to CI docs Changes related to documentations infra platform Non-amber Scala service paths labels Oct 29, 2026
@mengw15
mengw15 added this pull request to the merge queue Oct 29, 2026
Merged via the queue into apache:release/v1.3 with commit b92d0b2 Oct 29, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants