fix(uploads): raise body limit so images/PDFs/exes upload

The /api/uploads route used axum's standard Json extractor, whose default 2 MiB
body limit silently 413-rejected any base64 payload over ~2 MiB — small .txt
files worked but images, PDFs and executables never reached the handler. Apply
DefaultBodyLimit::max(64 MiB) to the upload route (a 32 MiB decoded file is ~43 MiB
of base64), so the handler runs and applies its own decoded-size cap.

Regression test: a ~3 MiB binary upload now returns 200 (kind=binary). Verified
live with a 3.0 MiB PNG, 3.1 MiB PDF and 3.1 MiB exe: all upload, classify
correctly, and binaries are handed to the model as path reminders.
This commit is contained in:
adm committed 2026-11-25 17:22:45 +01:00
1 parent 5117ecad7a
commit e79ee0e20e
3 files changed
+30 -2

No files matched your search

+8 -1
View File
@@ -80,7 +80,14 @@ fn build_router(state: AppState, auth: AuthConfig) -> Router {
)
.route("/api/sessions/{id}/messages", get(sessions::get_messages))
.route("/api/sessions/{id}/chat", post(sessions::session_chat))
.route("/api/uploads", post(uploads::upload))
.route(
"/api/uploads",
// Uploads arrive as base64 JSON: a 32 MiB decoded file becomes
// ~43 MiB on the wire, well over axum's 2 MiB default body limit
// (which silently 413-rejected images/PDFs/exes). Allow 64 MiB so
// the handler runs and applies its own decoded-size cap.
post(uploads::upload).layer(axum::extract::DefaultBodyLimit::max(64 * 1024 * 1024)),
)
.route(
"/api/settings/defaults",
get(sessions::get_defaults).put(sessions::put_defaults),