PG1204 opened a new issue, #8634:
URL: https://github.com/apache/texera/issues/8634
### What happened?
`ImageTaskCodegen.parsePython` decodes a chat provider's reply at four sites
(lines 109-110, 118-119, 123-124, 152-153):
if body.get("choices"):
return body["choices"][0].get("message", {}).get("content",
json.dumps(body))
A truthy `choices` is not necessarily a list of dictionaries. When a
provider returns a 200 whose body is `{"choices": [null]}`, `{"choices":
[{"message": null}]}`, `{"choices": "bad"}` or `{"choices": [42]}`, calling
`.get` on that value raises `AttributeError`.
`_parse_response` wraps the branch in `except (KeyError, IndexError,
TypeError)`, which does not cover `AttributeError`, so it escapes to the
per-row handler and the result column shows `Request failed: AttributeError
...` instead of the raw JSON body the parser is meant to fall
back to.
Two further shapes are wrong without raising: a null `content` writes Python
`None` into the cell, and a list-valued `content` (`[{"type": "text", "text":
...}]`, which some OpenAI-compatible providers return) writes the raw list
instead of the text.
This is reachable in practice for `image-text-to-text`, where models do have
live third-party providers.
This is the same defect #8617 fixes for `TextGenCodegen` and
`QaRankingCodegen`, raised in review there by @Copilot. These four sites came
from #7920 and were left out of #8617 to keep that diff to the files under
review.
### How to reproduce?
Run the operator with `image-text-to-text` against a model whose cheapest
provider is a third-party chat provider, and have that provider return a 200
whose `choices` is not a list of dictionaries. The row's result column shows
`Request failed: AttributeError ...` rather than the serialized body.
### 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
```shell
```
--
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]