Skip to content

feat: Add HTTP request body size limit to OpenAI frontend - #8787

Merged
pskiran1 merged 16 commits into
mainfrom
spolisetty/tri-1015-psirt-triton-openai-frontend-accepts-a-single-64-mib-json
May 29, 2026
Merged

feat: Add HTTP request body size limit to OpenAI frontend#8787
pskiran1 merged 16 commits into
mainfrom
spolisetty/tri-1015-psirt-triton-openai-frontend-accepts-a-single-64-mib-json

Conversation

@pskiran1

@pskiran1 pskiran1 commented May 18, 2026

Copy link
Copy Markdown
Member

What does the PR do?

Adds an HTTP request body size limit to the Triton OpenAI frontend to reject oversized requests before JSON parsing. The PR introduces a FastAPI/ASGI middleware that:

  • Rejects requests early when Content-Length exceeds the configured limit.
  • Counts streamed/chunked request bodies and rejects them once they exceed the limit.
  • Returns a structured OpenAI-style error response with HTTP 413 content_too_large.
  • Rejects malformed Content-Length headers with HTTP 400 invalid_content_length.

The default limit is 67108864 bytes / 64 MiB, and it can be configured with the new --http-max-input-size CLI option.

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

Check the conventional commit type
box here and add the label to the github PR.

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

Related PRs:

Where should the reviewer start?

Test plan:

  • CI Pipeline ID: 52210748

Caveats:

Background

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

@pskiran1 pskiran1 added the PR: fix A bug fix label May 18, 2026
pskiran1 and others added 4 commits May 18, 2026 10:22
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…s-a-single-64-mib-json' of https://github.com/triton-inference-server/server into spolisetty/tri-1015-psirt-triton-openai-frontend-accepts-a-single-64-mib-json
@pskiran1
pskiran1 requested review from mudit-eng, whoisj and yinggeh May 18, 2026 15:50
Comment thread python/openai/openai_frontend/utils/utils.py Outdated
pskiran1 and others added 2 commits May 20, 2026 16:00
Co-authored-by: Yingge He <157551214+yinggeh@users.noreply.github.com>
Comment thread python/openai/openai_frontend/utils/utils.py
@yinggeh

yinggeh commented May 20, 2026

Copy link
Copy Markdown
Contributor

Should be feat not fix

Comment thread python/openai/openai_frontend/frontend/fastapi/middleware/request_size.py Outdated
Comment thread python/openai/openai_frontend/frontend/fastapi/middleware/request_size.py Outdated
Comment thread python/openai/tests/test_request_size.py Outdated
Comment thread python/openai/tests/test_request_size.py Outdated
@pskiran1
pskiran1 requested a review from yinggeh May 20, 2026 14:26
@pskiran1 pskiran1 changed the title fix: Add HTTP request body size limit to OpenAI frontend feat: Add HTTP request body size limit to OpenAI frontend May 20, 2026
@pskiran1 pskiran1 added PR: feat A new feature and removed PR: fix A bug fix labels May 20, 2026
Comment thread python/openai/openai_frontend/frontend/fastapi/middleware/request_size.py Outdated
Comment thread python/openai/tests/test_request_size.py Outdated
Comment thread python/openai/openai_frontend/utils/utils.py
pskiran1 added 4 commits May 21, 2026 21:48
…s-a-single-64-mib-json' of https://github.com/triton-inference-server/server into spolisetty/tri-1015-psirt-triton-openai-frontend-accepts-a-single-64-mib-json
@pskiran1
pskiran1 requested review from whoisj and yinggeh May 22, 2026 09:20

@whoisj whoisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, but I am not a FastAPI expert. I'll leave it to @pskiran1 and @yinggeh to decide if this is correct or not.

@pskiran1
pskiran1 merged commit 8cb2b77 into main May 29, 2026
3 checks passed
@pskiran1
pskiran1 deleted the spolisetty/tri-1015-psirt-triton-openai-frontend-accepts-a-single-64-mib-json branch May 29, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feat A new feature

Development

Successfully merging this pull request may close these issues.

4 participants