fix(translation): fail closed on malformed Responses input - #868
Open
leseb wants to merge 1 commit into
Open
Conversation
The Responses-to-Chat Completions translation silently dropped or synthesized malformed input instead of rejecting it: scalar input became an empty message list, non-object items were skipped, missing message role/content were defaulted, and function calls and outputs missing call_id, name, arguments, or output were dropped. The backend then received a different, valid-looking Chat Completions request and could not reject the client's invalid Responses request. Validate translation-required structure before canonical state erases the original scalar input, and return the existing TranslationError to HTTP 400 path for unsupported input types and missing required item fields. Valid requests are unchanged. Closes praxis-proxy#552 Signed-off-by: Sébastien Han <seb@redhat.com>
leseb
enabled auto-merge
September 2, 2026 09:57
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.
Summary
The Responses-to-Chat Completions translation silently dropped or synthesized malformed input (scalar
inputbecame an empty message list; non-object items were skipped; missing messagerole/contentwere defaulted; function calls/outputs missingcall_id,name,arguments, oroutputwere dropped), so the backend received a different, valid-looking Chat Completions request instead of the client's invalid Responses request being rejected. This change validates translation-required structure before canonical state erases the original scalar input and routes unsupported input types and missing required item fields through the existingTranslationError→ HTTP 400 path, leaving valid requests byte-for-byte unchanged.Related issue
Closes #552
Validation
cargo test -p praxis-ai-apis(2,589 passed, +2 doctests)cargo test -p praxis-tests-integration responses_to_chat_completions(7 passed, incl. newresponses_to_chat_completions_rejects_malformed_input_before_upstream, which asserts the backend receives no request)make lintmake build,git diff --checkChecklist
responses-to-chat-completions.yamlwith a new functional test.make lintdoc-sync checks pass).Signed-off-bytrailer.Breaking changes
Requests with malformed Responses
inputthat were previously silently repaired now return HTTP 400 with aninvalid_request_error. Well-formed requests are unaffected. This aligns the proxy with the Open Responses schema; any client relying on silent repair must send schema-valid input.