Repository navigation
fix(workflow-operator, v1.3): degrade instead of raising on malformed chat responses - #8993
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…responses (#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. --------- (backported from commit 65a748a) Co-authored-by: Meng Wang <mengw15@uci.edu>
Contributor
Author
|
The cherry-pick conflicted and was committed with conflict markers. Resolve the conflicts on this branch, then mark this PR ready for review. Conflicting files:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Automated backport of #8617 to
release/v1.3.Source: 65a748a · automation run
Any related issues, documentation, discussions?
Backport of #8617. Originally linked #8486.
How was this PR tested?
Release-branch CI runs on this branch once the conflicts are resolved and this PR is marked ready for review.
Was this PR authored or co-authored using generative AI tooling?
No.