The GitHub Actions job "Release Auditing" on 
texera.git/gh-readonly-queue/main/pr-8617-82ab13483dff640e580850d6f534964ae2d68029
 has failed.
Run started by GitHub user mengw15 (triggered by mengw15).

Head commit for run:
09a04ceb75592a66a41d0f06b6ea6084427bcd64 / Prateek Ganigi 
<[email protected]>
fix(workflow-operator): degrade instead of raising on malformed chat responses 
(#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 #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 #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.

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

With regards,
GitHub Actions via GitBox

Reply via email to