๐ Bug Report: Failed source upload shows the HTTP status text instead of the server's error message
๐ Description
When a source upload or a remote source is rejected, the toast shows the HTTP status text instead of the reason the backend returns.
frontend/src/upload/Upload.tsx handles a non-2xx response the same way in uploadFile (L601) and uploadRemote (L691):
} else {
handleTaskFailure(clientTaskId, xhr.statusText || undefined);
}
xhr.responseText is never read. But /api/upload returns a specific JSON message for these failures (docsgpt/api/user/sources/upload.py L512-549, status 413):
"<name>: ZIP archive failed safety validation""File exceeds the <n>-byte upload limit"- the STT size-limit message
So the user sees "Request Entity Too Large" and never learns why. Over HTTP/2 statusText is an empty string, so the toast gives no reason at all.
The frontend already has a parser for this body: parseUploadErrorMessage in frontend/src/constants/fileUpload.ts:339. Chat attachments use it (components/message-input/attachmentUpload.ts), but source uploads do not.
๐ Reproduction steps
- Create a ZIP that fails the safety check, e.g. one with an entry named
../evil.txt. - Knowledge โ Upload new โ Upload File, add the ZIP, click Add to Knowledge.
- Watch the upload toast.
๐ Expected behavior
The toast shows the server's message, evil.zip: ZIP archive failed safety validation, and falls back to the status text only when the body has no message.
๐ Actual Behavior with Screenshots
The toast shows Upload failed ยท evil.zip ยท Request Entity Too Large, while the response body to POST /api/upload was:
HTTP/1.1 413 Request Entity Too Large
{"message":"evil.zip: ZIP archive failed safety validation","success":false}
Reproduced on the develop images (arc53/docsgpt and arc53/docsgpt-fe, built 2026-10-19) with deployment/docker-compose-hub.yaml.
๐ป Operating system
Windows
What browsers are you seeing the problem on?
Chrome
๐ค What development environment are you experiencing this bug on?
Docker
๐ Environment variables
API_KEY, LLM_NAME, VITE_API_STREAMING, INTERNAL_KEY, JWT_SECRET_KEY, ENCRYPTION_SECRET_KEY
๐ Provide any additional context for the Bug.
Suggested fix: in both else-branches, use parseUploadErrorMessage(xhr.responseText) ?? (xhr.statusText || undefined).
Some error branches send error instead of message (e.g. upload.py L601, L611, L706, used by the remote-source path). The helper could fall back to that key too.
Upload.test.tsx already fakes XMLHttpRequest, so a 413-with-JSON-body case is easy to add.
๐ Relevant log output
WARNING in upload: Rejected unsafe ZIP upload evil.zip: ZIP contains a path traversal attempt: ../evil.txt
"POST /api/upload HTTP/1.1" 413 Request Entity Too Large
๐ Have you spent some time to check if this bug has been raised before?
- [x] I checked and didn't find similar issue
๐ Are you willing to submit PR?
Yes, I am willing to submit a PR!
๐งโโ๏ธ Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Assigned to @AbdulWasih05.
- Open a PR or post progress within 14 days; otherwise the issue goes back to other contributors.
- Read
CONTRIBUTING.mdandfrontend/DESIGN.md. - Include a screenshot or short recording of the corrected upload error, and regression tests for local and remote uploads, JSON
message/errorbodies, and fallback behavior.
Automated triage. A maintainer will follow up.
Fixed on main in b629d4827, upload failures now show the server's message instead of the status text.