You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(kb): every knowledge upload over 1 MiB gets 413 — the app-wide validation middleware's JSON cap applies to multipart uploads, and the 10 MB limit is hardcoded in 3 more places #19712
Uploading any knowledge file larger than 1 MiB fails with 413 Content Too Large, even though the upload route allows 10 MB. Seen on 2026-10-26 on a node updated to be85b7e1ed: POST /api/knowledge_base/upload returned 413. The frontend RUM log recorded the same 413 at 22:19:12.
Root cause
autobot-backend/middleware/validation_middleware.py:56 sets MAX_BODY_BYTES: Final[int] = 1 * 1024 * 1024. ValidationMiddleware is registered app-wide by initialization/middleware.py:configure_validation, and its docstring says it "Rejects oversized bodies (> 1 MiB) with HTTP 413".
The only exemptions are _EXEMPT_PREFIXES (health, docs and static) and _BODY_SCAN_EXEMPT_RE, which matches only ^/api/chats/[^/]+/save$. Neither covers multipart upload routes, so the 1 MiB perimeter cap wins over every route's own limit.
The upload limit is also defined three more times, as hardcoded literals that are not config:
autobot-frontend/src/constants/knowledgeUpload.tsKNOWLEDGE_UPLOAD_MAX_MB = 10 (a hand-kept mirror)
web server client_max_body_size 10m on most locations
Fix
Multipart upload routes are measured by their own route limit, not the 1 MiB JSON cap. The perimeter cap keeps protecting JSON and form bodies.
The upload limit is one env-backed SSOT value. The frontend reads it from the backend instead of mirroring it. The web server limit is generated from the same value.
A 5 MB PDF uploads through the Knowledge upload dialog and is chunked into the KB. A test posts a body larger than 1 MiB to /api/knowledge_base/upload and gets no 413 from the middleware.
A JSON body larger than 1 MiB to a non-upload route still gets 413. A test pins this.
MAX_FILE_SIZE_MB is read from one config/env value. knowledgeUpload.ts no longer hardcodes 10, and gets the value from the backend.
The web server body limit for the upload route comes from the same value.
Host: after the builtin update, a 5 MB upload succeeds on the node.
The 1 MiB cap applies to every multipart route, not only this one. The PR for this issue lifts it only for /api/knowledge_base/upload, whose limit is confirmed. Read by grep of each route file on main, not traced through helpers and not run:
Verified against main at the merge train (PR #20661), merge 6c34ee1. Members touching this issue: #20544.
AC
Evidence
A 5 MB PDF uploads through the dialog; a test posts over 1 MiB to /api/knowledge_base/upload and gets no 413
NOT ticked. Middleware now exempts multipart to that route (middleware/validation_middleware.py:80, _OWN_LIMIT_MULTIPART_RE, used at line 229) and validation_middleware_test.py:341 pins it, but with a lowered test cap and 100-byte file, not a real 5 MB body, and the dialog path is not tested end to end.
A JSON body over 1 MiB to a non-upload route still gets 413, pinned
Ticked. validation_middleware_test.py:190 (test_oversized_body_rejected), :346 (JSON to the upload route keeps the cap), :350 (multipart to another route keeps it).
MAX_FILE_SIZE_MB from one env value; knowledgeUpload.ts no longer hardcodes 10 and gets it from the backend
Ticked. knowledge/upload_limit.py:16: env_int("AUTOBOT_KB_UPLOAD_MAX_MB", 10), imported by api/knowledge.py:113; served at GET /knowledge_base/upload/limit (api/knowledge_upload_limit.py); autobot-frontend/src/constants/knowledgeUpload.ts no longer defines it and composables/knowledge/useKnowledgeUploadLimit.ts reads it.
Web server body limit for the upload route comes from the same value
NOT ticked. client_max_body_size 10m is still a literal in autobot-slm-backend/ansible/roles/slm_manager/templates/autobot-slm.conf.j2:65 and the proxy configs; nothing generates it from AUTOBOT_KB_UPLOAD_MAX_MB.
Host: after the builtin update, a 5 MB upload succeeds on the node
NOT ticked. Host behaviour; a merge is not host evidence.
Host check on 2026-11-02, read-only, on the local node after its update to 6c34ee1:
The deployed validation_middleware.py is byte-identical to that commit and holds the upload route's exemption (_OWN_LIMIT_MULTIPART_RE).
The recent lines of the backend log show no upload and no 413.
That shows the code is deployed, not that the criterion is met. No upload has been tried: it writes to the knowledge base, so the 5 MB upload stays with the owner, and the host criterion stays open.
The web server's body limit wasn't checked: the search of its enabled sites returned nothing, which may mean no access rather than no setting.
Activity
mrveiss commentedon Nov 1, 2026
The 1 MiB cap applies to every multipart route, not only this one. The PR for this issue lifts it only for
/api/knowledge_base/upload, whose limit is confirmed. Read by grep of each route file on main, not traced through helpers and not run:api/files.py,api/conversation_file_upload.pyapi/voice.py,api/multimodal.pyread_capped_audiotranscriber/routes/recordings.pyMAX_FILE_SIZE, streamedllc/api/agent_api.py,llc/api/work_items.pyapi/chat_knowledge.py,api/conversation_files.py,api/themes.py,media/image_upload.pyEach stays capped at 1 MiB until checked and added to
_OWN_LIMIT_MULTIPART_RE, so this issue stays open for them.fix(knowledge): the upload route refuses an oversize file before read…
chore(tests): repin the reach floors on the merged tree (#19712)
mrveiss commentedon Nov 2, 2026
Verified against
mainat the merge train (PR #20661), merge 6c34ee1. Members touching this issue: #20544./api/knowledge_base/uploadand gets no 413middleware/validation_middleware.py:80,_OWN_LIMIT_MULTIPART_RE, used at line 229) andvalidation_middleware_test.py:341pins it, but with a lowered test cap and 100-byte file, not a real 5 MB body, and the dialog path is not tested end to end.validation_middleware_test.py:190(test_oversized_body_rejected),:346(JSON to the upload route keeps the cap),:350(multipart to another route keeps it).MAX_FILE_SIZE_MBfrom one env value;knowledgeUpload.tsno longer hardcodes 10 and gets it from the backendknowledge/upload_limit.py:16:env_int("AUTOBOT_KB_UPLOAD_MAX_MB", 10), imported byapi/knowledge.py:113; served atGET /knowledge_base/upload/limit(api/knowledge_upload_limit.py);autobot-frontend/src/constants/knowledgeUpload.tsno longer defines it andcomposables/knowledge/useKnowledgeUploadLimit.tsreads it.client_max_body_size 10mis still a literal inautobot-slm-backend/ansible/roles/slm_manager/templates/autobot-slm.conf.j2:65and the proxy configs; nothing generates it fromAUTOBOT_KB_UPLOAD_MAX_MB.The issue stays open: 3 criteria remain.
mrveiss commentedon Nov 2, 2026
Host check on 2026-11-02, read-only, on the local node after its update to 6c34ee1:
validation_middleware.pyis byte-identical to that commit and holds the upload route's exemption (_OWN_LIMIT_MULTIPART_RE).That shows the code is deployed, not that the criterion is met. No upload has been tried: it writes to the knowledge base, so the 5 MB upload stays with the owner, and the host criterion stays open.
The web server's body limit wasn't checked: the search of its enabled sites returned nothing, which may mean no access rather than no setting.