Skip to content

fix(frontend): return 400 for deprecated function_call and functions - #17507

Open
mananpatelll wants to merge 1 commit into
ai-dynamo:mainfrom
mananpatelll:mananpatelll/fix-function-call-400
Open

mananpatelll wants to merge 1 commit into
ai-dynamo:mainfrom
mananpatelll:mananpatelll/fix-function-call-400

Conversation

@mananpatelll

@mananpatelll mananpatelll commented Oct 28, 2026 •

Copy link
Copy Markdown

Overview

Chat completions returns 501 for requests with the deprecated function_call or functions fields. OpenAI SDKs retry 5xx, so older clients keep retrying a request that can never succeed. This makes it a 400 with the same message.

Key Changes

2 lines of core logic.

  • openai.rs: validate_chat_completion_unsupported_fields uses unsupported_content_error instead of not_implemented_error. That's the existing 400 helper for unsupported features (Responses uses it for unsupported content), and it keeps the request metric at NotImplemented. The failure counter now says invalid_request instead of not_implemented for these requests.
  • frontend_protocol_validation_http.rs: new test.

Validation

  • function_call set: 501 before, 400 now, streaming or not.
  • functions set: 501 before, 400 now, streaming or not.

chat_completions_reject_deprecated_function_fields_as_bad_request sends both fields with and without streaming and checks the status, message, and metric. It fails on main with a 501. Ran on macOS with --no-default-features.

Issues and Ongoing Work

Pull Request Checklist
  • I used Dynamo's /pr-checklist skill.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Chat-completion requests that include the deprecated function_call or functions fields now receive a clear HTTP 400 response, including in streaming requests. These requests are rejected before processing, with a message identifying the deprecated field.

OpenAI SDKs retry 5xx, so the 501 made older clients retry a request that can never succeed. The error messages and the NotImplemented request metric stay the same.

Signed-off-by: Manan Patel <144215944+mananpatelll@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mananpatelll
mananpatelll requested review from a team as code owners October 28, 2026 07:17
@copy-pr-bot

copy-pr-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@mananpatelll
mananpatelll temporarily deployed to external_collaborator October 28, 2026 07:17 — with GitHub Actions Inactive
@mananpatelll
mananpatelll temporarily deployed to external_collaborator October 28, 2026 07:17 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi mananpatelll! Thank you for contributing to ai-dynamo/dynamo.

Just a reminder: The NVIDIA Test Github Validation CI runs an essential subset of the testing framework to quickly catch errors.Your PR reviewers may elect to test the changes comprehensively before approving your changes.

🚀

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f38fb53 and 3d5b202.

Files selected for processing: 2
  • lib/llm/src/http/service/openai.rs
  • lib/llm/tests/frontend_protocol_validation_http.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

Deprecated function_call and functions fields in chat-completion requests now produce unsupported-content HTTP 400 responses. Tests check unary and streaming behavior, error metrics, and that the engine receives no requests.

Changes

Deprecated chat-completion fields

Layer / File(s) Summary
400 handling and regression coverage
lib/llm/src/http/service/openai.rs, lib/llm/tests/frontend_protocol_validation_http.rs
The validator routes deprecated function_call and functions fields to unsupported-content errors with HTTP 400 responses and the NotImplemented metric classification. Tests cover unary and streaming requests, field-specific messages, metrics, and engine request counts.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 3d5b2

Deprecated function fields are intended to return 400 without reaching the engine. No merge-blocking concern is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: returning HTTP 400 for deprecated function_call and functions fields.
Description check Passed The description includes all required sections, explains the problem and implementation, documents validation results, identifies ongoing work, and includes the checklist.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

// validate_chat_completion_unsupported_fields,
// then a field was used that is unsupported. We will log an error message
// and early return a 501 NOT_IMPLEMENTED status code. Otherwise, proceeed.
// then a field was used that is unsupported. We early return a

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the four-line comment above this validation call. It narrates the immediately following if let Err and early return; the 400 status and its rationale are already documented on unsupported_content_error. It adds no lasting constraint.

🤖 AI Fix

Delete the four-line comment beginning Handle unsupported fields above validate_chat_completion_unsupported_fields(&request).

This branch was previously deployed

1 inactive deployment
external_collaborator — 3d5b2029 Deployed Oct 28, 2026 by mananpatelll via ok-to-test #40468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Pull request is from an external contributor fix frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant