DocsGPT icon indicating copy to clipboard operation
DocsGPT copied to clipboard

๐Ÿ› Bug Report: Failed source upload shows the HTTP status text instead of the server's error message

Open AbdulWasih05 opened this issue 1 month ago โ€ข 2 comments

๐Ÿ“œ 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

  1. Create a ZIP that fails the safety check, e.g. one with an entry named ../evil.txt.
  2. Knowledge โ†’ Upload new โ†’ Upload File, add the ZIP, click Add to Knowledge.
  3. 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}
Image

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

AbdulWasih05 avatar Oct 20 '26 11:10 AbdulWasih05

Assigned to @AbdulWasih05.

  • Open a PR or post progress within 14 days; otherwise the issue goes back to other contributors.
  • Read CONTRIBUTING.md and frontend/DESIGN.md.
  • Include a screenshot or short recording of the corrected upload error, and regression tests for local and remote uploads, JSON message/error bodies, and fallback behavior.

Automated triage. A maintainer will follow up.

arc53-machine avatar Oct 20 '26 11:10 arc53-machine

Fixed on main in b629d4827, upload failures now show the server's message instead of the status text.

ManishMadan2882 avatar Oct 30 '26 00:10 ManishMadan2882