Malformed chat responses abort the run in the text-generation and QA codegens

Open
#8,486 1 comment 0 reactions 1 assignee View on GitHub

@PG1204 is already working on this.

Since Sep 10, 2026.

Assessment

This issue has not been assessed yet.

Description

What happened?

TextGenCodegen.parsePython extracts the chat response with no guard at all:

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

QaRankingCodegen.parsePython guards only on key presence, at three sites:

if "choices" in body:
    return body["choices"][0]["message"]["content"]

Both raise on a malformed provider response rather than degrading:

  • {"choices": []}IndexError (the in body check passes, the list is empty)
  • {"choices": [{}]}KeyError: 'message'
  • {"choices": [{"message": {}}]}KeyError: 'content'

parsePython runs once per row, so a single malformed response from one provider aborts the entire run. The native hf-inference paths in the same functions already degrade politely via body.get("answer", json.dumps(body)), so the two paths are inconsistent.

This path is reachable in practice: of the top 100 models by downloads, 45 for text-generation, 37 for question-answering and 72 for sentence-similarity have a live third-party provider, so the chat branch does execute for these tasks.

This is the same defect #7920 fixed in ImageTaskCodegen, raised in review by @Ma77Ball. The remaining sites are in code merged earlier (#7798) and were left out of that PR to keep the diff focused.

How to reproduce?

Run the operator with text-generation (or any of the QA/ranking tasks) against a model whose cheapest provider is a third-party chat provider, and have that provider return a 200 with an empty choices list or a choice missing message/content. The operator raises and the run aborts, instead of writing the raw body into the result column.

Version/Branch

1.4.0-incubating-SNAPSHOT (main)

Commit Hash (Optional)

No response

What browsers are you seeing the problem on?

No response

Relevant log output

Dominant language
Scala
Stars
316
Forks
189
Avg merge
2d 20h
Merged PRs (30d)
198

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/texera

All issues in apache/texera

Similar issues

More Scala issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.