INNER CODE UNIT · Python
handle_restx_request_entity_too_large
arc53/DocsGPT · docsgpt/app.py:167
def handle_restx_request_entity_too_large(_error):
"""Keep Flask-RESTX from replacing the configured upload-limit response."""
return _upload_limit_error_payload(), 413
@app.before_request
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