PG1204 opened a new pull request, #9102:
URL: https://github.com/apache/texera/pull/9102
### What changes were proposed in this PR?
`ImageTaskCodegen.parsePython` decoded a chat provider's reply at four sites
by indexing into `choices[0]` and calling `.get` on the result. A truthy
`choices` that is not a list of dictionaries — `[null]`, `[{"message": null}]`,
`"bad"`, `[42]` — therefore raised `AttributeError`, which `_parse_response`'s
`except (KeyError, IndexError, TypeError)` does not catch. The row's cell ended
up reading "Request failed" instead of the body.
All four now delegate to `_chat_message_content`, the shared type-checked
helper added in #8617, which validates every level and returns `None` when the
body is not a readable chat response. Each branch then falls back to its native
shape or to `json.dumps(body)`, as before.
This completes the work #8617 started: that PR deliberately left these four
sites out to keep its diff to the files under review.
### Any related issues?
Closes #8634
### How was this PR tested?
Written test-first: the five image tasks were added to
`HuggingFaceParseBehaviorSpec`, which executes the generated parser against 12
malformed response shapes. They fail against the current code with exactly the
reported error — `task=visual-question-answering body={"choices": [null]}`
raising `AttributeError` — and pass with the change.
168 tests pass across the Hugging Face suites,
`PythonCodeRawInvalidTextSpec` py-compiles all 117 operators, and
`scalafmtCheck` and `scalafix --check` are clean. Reverting the codegen and
re-running makes three tests fail.
One shape was moved out of the shared malformed list: `[{"generated_text":
"x"}]` is a success path for the image codegens and an unrecognised shape for
the text ones, so it is now asserted per task instead.
### 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]