INNER CODE UNIT · Python
enforce_document_upload_request_size_limit
arc53/DocsGPT · docsgpt/app.py:173
def enforce_document_upload_request_size_limit():
"""Bound multipart parsing for public file-upload routes only.
Internal worker index uploads are intentionally excluded; they are trusted
service traffic and can legitimately exceed the end-user document limit.
"""
if request.method == "OPTIONS" or not is_document_upload_path(request.path):
return None
request_limit = (
settings.PARSE_SPEC_MAX_BYTES
if request.path == "/api/parse_spec" and request.is_json
else settings.UPLOAD_MAX_REQUEST_BYTES
)
request.max_content_length = request_limit
if (
request.content_length is not None
and request.content_length > request_limit
):