Skip to content

fix(translation): fail closed on malformed Responses input - #868

Open
leseb wants to merge 1 commit into
praxis-proxy:mainfrom
leseb:leseb/validate-issue-552
Open

fix(translation): fail closed on malformed Responses input#868
leseb wants to merge 1 commit into
praxis-proxy:mainfrom
leseb:leseb/validate-issue-552

Conversation

@leseb

@leseb leseb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The Responses-to-Chat Completions translation silently dropped or synthesized malformed input (scalar input became an empty message list; non-object items were skipped; missing message role/content were defaulted; function calls/outputs missing call_id, name, arguments, or output were 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 existing TranslationError → HTTP 400 path, leaving valid requests byte-for-byte unchanged.

Related issue

Closes #552

Validation

  • Unit tests — cargo test -p praxis-ai-apis (2,589 passed, +2 doctests)
  • Integration or functional tests — cargo test -p praxis-tests-integration responses_to_chat_completions (7 passed, incl. new responses_to_chat_completions_rejects_malformed_input_before_upstream, which asserts the backend receives no request)
  • make lint
  • Additionally: make build, git diff --check

Checklist

  • I reviewed every changed line and can explain the change.
  • New capabilities include an example config and functional example test. — N/A: hardening of an existing capability; reuses responses-to-chat-completions.yaml with a new functional test.
  • User-facing behavior and generated documentation are updated. — Malformed input now returns HTTP 400 instead of being silently altered; no generated docs affected (make lint doc-sync checks pass).
  • Performance-sensitive changes include appropriate benchmark or load-test evidence. — N/A: validation on the existing request-parse path; no new buffering or clones.
  • Commits are signed and include a Signed-off-by trailer.

Breaking changes

Requests with malformed Responses input that were previously silently repaired now return HTTP 400 with an invalid_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.

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
leseb requested review from a team and aslakknutsen September 2, 2026 08:52
@leseb
leseb enabled auto-merge September 2, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Responses-to-Chat translation silently drops malformed input instead of preserving backend validation

1 participant