Repository navigation
fix: support 512 MiB task and chat attachments - #252
Conversation
BaaRai
left a comment
There was a problem hiding this comment.
The backend side is sound: the 500 MiB cap, the 413 for oversized bodies and combined payloads, the temp cleanup, and the boundary tests all check out.
Two things need to land before merge:
-
README nginx example. The location block does not set client_max_body_size, so nginx keeps its 1 MiB default and returns 413 before the request reaches ARTEX. This already affected the old 128 MiB limit, but the new goal makes it visible. Please add:
client_max_body_size 501m;
proxy_request_buffering off;
The first allows a 500 MiB file plus a small multipart overhead. The second stops nginx from buffering the whole upload to its own temp file before forwarding it. -
Client-side precheck. web/src/lib/api.ts chatUpload sends the FormData without checking the total size, so an oversized upload is sent until the server rejects it, and the browser may surface a network error instead of the 413 message. Please sum file.size before fetch and throw a clear error above 500 MiB (500 * 1024 * 1024), in that function so task, session and staging all get it.
While here: the 400 message still says "or size limit exceeded" although that case now returns 413, the 413 text is duplicated, and the 1 MiB multipart overhead is a literal. A named constant and one message would keep the handler readable.
Out of scope for this PR, but worth tracking separately: ParseMultipartForm spills the upload to a temp file and saveUpload copies it to uploads/, so a 500 MiB upload writes about 1 GiB; saveUpload leaves a partial destination on failure; and uniqueUploadPath does stat then create, so two concurrent uploads with the same filename can clobber each other. I am not asking for those here.
|
a "500 MB" upload limit is almost always configured as 512 MB under the hood. |
|
Hostile merge-gate review (Chaos Labs, 2026-11-16): PASS on all four attack surfaces tried — (a) MaxBytesReader bounds the whole body incl. part headers; stdlib caps parts at 1000; the 500MiB-exact vs 501MiB boundary is parser-computed, not attacker-controlled. (b) Temp-file cleanup verified guaranteed on ALL error paths (Go 1.26 readForm defer + the new defer RemoveAll; test asserts spill-dir emptiness on both 413 paths). (c) The boundary test is genuine — it fails against the old 128MiB code on two independent assertions. (d) Concurrency flag (non-blocking, follow-up): 500 MiB x concurrent uploads is an authenticated disk-fill vector on a small VM (~1 GiB transient per max request); a per-user quota is worth a follow-up. One mechanical blocker: green CI on this head is stale (31 commits behind at review time, and the python job this branch has never run) — rebase/update + fresh CI before merge. The content has landed in our private deploy line in the meantime (ChaosLabsInc/ARTEX#53). |
|
@BaaRai, the requested changes are addressed in 99a0d27:
The branch also includes the latest upstream main fetched for this update. Validation on the remote machine passed: all six backend upload-boundary cases, seven frontend upload tests, standalone TypeScript checking, polling/replay tests, Python tests and both shell test scripts. The static frontend build compiled successfully, but was stopped during its TypeScript phase after memory pressure on the shared machine; a complete static export and browser/nginx end-to-end upload remain unverified. CI for the updated head is awaiting maintainer approval for the fork workflow ( |
* build(web): 固定 BUILD_ID 实现同提交可复现前端构建 Next 默认每次 build 随机生成 BUILD_ID 并写入 index.html、RSC payload 等 300+ 个产物,同一提交两次构建的产物不一致。改为默认取当前提交短哈希 (git rev-parse --short HEAD,仓库根执行;无 .git 时回退 artex),可用 ARTEX_BUILD_ID 显式覆盖;同一提交重复构建产物逐字节一致。 来源:RuoJi6/ARTEX#123(LXD-8) * fix(task-llm): 单 profile 任务向进程级熔断器上报成败 任务链只有一个可用 profile 时 completeTaskLLM/streamTaskLLM 绕过 llmpool.Pool,成败从不进 s.llmHealth,/system/llm/ 的健康徽标因此失真。 taskLLMStreamHooks 新增 recordPass/recordFailure:镜像 Pool.Pass/Trip, 经 llmpool 导出的 ShouldFailover/IsHardFailure/TrimErr 用与 Pool 完全 一致的规则分类失败;profileID==0(绑定/全局路径)为 no-op,ctx 取消与 确定性 400 不动状态。调用点保证每条失败路径在透传/转移之前恰好上报 一次,流成功在 flush pending 之前上报 Pass。 LLM 记录页空态区分「录制已关闭」与「暂无记录」,补充英文词条。 来源:BaaRai/ARTEX#257(aminasoussi1986-creator),按本仓架构适配 * fix(chatupload): 附件上传上限提到 512 MiB 并返回准确 413 上限从 128 MiB 提到 512 MiB,按一次请求的合并文件数据计(各 file 字段 Size 之和),超出返回 413 与专门文案;MaxBytesReader 卡整个 请求体并另留 1 MiB multipart 开销,超限走 http.MaxBytesError 同样 返回 413,不再与解析错误混在 400。前端 chatUpload 发请求前按合并 大小本地预检(mock 模式同样拦截),nginx 示例补 client_max_body_size 513m 与 proxy_request_buffering off。 来源:BaaRai/ARTEX#252(renaesop),按本仓架构适配 * docs(fork-integrations): 记录 round50 三项同源适配的来源与边界 --------- Co-authored-by: 2217173240 <[email protected]>
BaaRai
left a comment
There was a problem hiding this comment.
Re-reviewed at 99a0d27. The gap between the old request and your rework is exactly what I wanted: 512 MiB is now the combined limit on both sides, the 413 carries one constant message, and the boundary test streams real parts of 512 MiB and 512 MiB + 1 and asserts the spill directory is empty on both rejection paths. I also ran the new frontend test: it transpiles the real api.ts and fails before FormData and fetch are touched, so it covers the actual code rather than a copy. The nginx example with 513m and proxy_request_buffering off matches the server budget.
Approving.
|
Merged at ea59a8a. All four checks green, including go at 7m39. The combined limit, the 413 message and the spill cleanup are covered on both sides now. Thanks. |
REA MCP app analysis often starts with uploading an APK or another application package. Many apps exceed the existing 128 MiB request limit, preventing analysis from starting through the normal task and chat upload flows.
This change allows up to 512 MiB of combined file data per request, with a separate 1 MiB allowance for multipart headers and boundaries. The shared frontend upload function rejects oversized selections before constructing FormData or sending a request, covering task, session and staging uploads. The README nginx example sets
client_max_body_size 513mandproxy_request_buffering offso the proxy accepts the upload without buffering the complete request first.The backend returns HTTP 413 for oversized file payloads or request bodies, uses one size-limit message, and cleans up multipart temporary files. Malformed uploads retain a separate HTTP 400 parse error.
Validation performed on the shein-artex remote machine:
go test -p 2 ./server -run '^TestChatUpload512MiBBoundary$' -count=1 -timeout=5m -v— passed all six cases, including exact single/combined 512 MiB payloads, one byte over the limit, request-body overflow, and cleanup.npm run test:upload— passed all seven tests covering preflight rejection and accepted boundaries for task/session/staging and mock uploads; included in web CI.npx tsc --noEmit— passed.npm run test:pollingandnpm run test:replay— passed.python3 scripts/posture_check_test.py— passed all seven tests.bash scripts/test-extract-changelog-section.shandbash scripts/test-bot-context.sh— passed.git diff --check— passed.The static frontend build compiled successfully, but the run was stopped during its TypeScript phase after memory pressure on the shared server; a complete static export is not verified. The standalone TypeScript check above passed. Browser/nginx end-to-end uploads remain unverified.
The updated branch includes current upstream main. CI for this head is awaiting maintainer approval for the fork workflow (
action_required); the current account does not have permission to approve it.