Skip to content

Malformed chat responses show "Request failed" instead of the body for image tasks #8634

Description

@PG1204

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions