PG1204 opened a new pull request, #8617:
URL: https://github.com/apache/texera/pull/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.


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