[GH-ISSUE #2473] [DOC]: Try Swagger API POST /v1/document/upload - fails to upload multipart file #1606

Closed
opened 2026-02-22 18:25:38 -05:00 by yindo · 4 comments
Owner

Originally created by @appdevhm88mt on GitHub (Oct 15, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/2473

How are you running AnythingLLM?

Docker (local)

What happened?

  1. [BUG]: Try Swagger API POST /v1/document/upload with any file get 500 Error: Internal Server Error

  2. Please see the attached error logs.
    v1-document-upload-error-logs.txt

  3. Expect to get the success response

  4. We have no this issue while using the AnytingLLM native workspace document upload feature

Are there known steps to reproduce?

See the failed screenshot as following:

api_v1_document_upload_01
](url)


api_v1_document_upload_02

Originally created by @appdevhm88mt on GitHub (Oct 15, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/2473 ### How are you running AnythingLLM? Docker (local) ### What happened? 1. [BUG]: Try Swagger API POST /v1/document/upload with any file get 500 Error: Internal Server Error 2. Please see the attached error logs. [v1-document-upload-error-logs.txt](https://github.com/user-attachments/files/17374588/v1-document-upload-error-logs.txt) 3. Expect to get the success response 4. We have no this issue while using the AnytingLLM native workspace document upload feature ### Are there known steps to reproduce? See the failed screenshot as following: ![api_v1_document_upload_01](https://github.com/user-attachments/assets/348e7e55-eb0a-41d7-8a45-7e9cc9adc5cf) ](url) [ ![api_v1_document_upload_02](https://github.com/user-attachments/assets/4a8c659c-1676-4115-87f4-958c516a842f) ](url)
yindo added the documentationwontfix labels 2026-02-22 18:25:38 -05:00
yindo closed this issue 2026-02-22 18:25:38 -05:00
Author
Owner

@timothycarambat commented on GitHub (Oct 15, 2024):

Cannot destructure property 'originalname' of 'request.file' as it is undefined. TypeError: Cannot destructure property 'originalname' of 'request.file' as it is undefined.
    at /workspaces/anything-llm_dev-container/server/endpoints/api/document/index.js:85:17
    at Layer.handle [as handle_request] (/workspaces/anything-llm_dev-container/server/node_modules/express/lib/router/layer.js:95:5)
    at next (/workspaces/anything-llm_dev-container/server/node_modules/express/lib/router/route.js:149:13)
    at /workspaces/anything-llm_dev-container/server/utils/files/multer.js:72:5
    at done (/workspaces/anything-llm_dev-container/server/node_modules/multer/lib/make-middleware.js:45:7)
    at indicateDone (/workspaces/anything-llm_dev-container/server/node_modules/multer/lib/make-middleware.js:49:68)
    at Multipart.<anonymous> (/workspaces/anything-llm_dev-container/server/node_modules/multer/lib/make-middleware.js:166:7)
    at Multipart.emit (/workspaces/anything-llm_dev-container/server/lib/events.js:517:28)
    at emitCloseNT (/workspaces/anything-llm_dev-container/server/lib/internal/streams/destroy.js:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {stack: "TypeError: Cannot destructure property 'origi…ons (node:internal/process/task_queues:81:21)", message: "Cannot destructure property 'originalname' of 'request.file' as it is undefined."}

This certainly has to do with how Swagger file uploading works since it does not seem to be retaining the multipart data of the file object. Are you able to replicate this via tradional POST/Fetch request as opposed to using the Swagger UI only?

@timothycarambat commented on GitHub (Oct 15, 2024): ``` Cannot destructure property 'originalname' of 'request.file' as it is undefined. TypeError: Cannot destructure property 'originalname' of 'request.file' as it is undefined. at /workspaces/anything-llm_dev-container/server/endpoints/api/document/index.js:85:17 at Layer.handle [as handle_request] (/workspaces/anything-llm_dev-container/server/node_modules/express/lib/router/layer.js:95:5) at next (/workspaces/anything-llm_dev-container/server/node_modules/express/lib/router/route.js:149:13) at /workspaces/anything-llm_dev-container/server/utils/files/multer.js:72:5 at done (/workspaces/anything-llm_dev-container/server/node_modules/multer/lib/make-middleware.js:45:7) at indicateDone (/workspaces/anything-llm_dev-container/server/node_modules/multer/lib/make-middleware.js:49:68) at Multipart.<anonymous> (/workspaces/anything-llm_dev-container/server/node_modules/multer/lib/make-middleware.js:166:7) at Multipart.emit (/workspaces/anything-llm_dev-container/server/lib/events.js:517:28) at emitCloseNT (/workspaces/anything-llm_dev-container/server/lib/internal/streams/destroy.js:132:10) at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {stack: "TypeError: Cannot destructure property 'origi…ons (node:internal/process/task_queues:81:21)", message: "Cannot destructure property 'originalname' of 'request.file' as it is undefined."} ``` This certainly has to do with how Swagger file uploading works since it does not seem to be retaining the multipart data of the file object. Are you able to replicate this via tradional POST/Fetch request as opposed to using the Swagger UI only?
Author
Owner

@appdevhm88mt commented on GitHub (Oct 20, 2024):

Hi,
I can successfully use Postman to POST the request with file object. So it's Swagger issue?

@appdevhm88mt commented on GitHub (Oct 20, 2024): Hi, I can successfully use Postman to POST the request with file object. So it's Swagger issue?
Author
Owner

@timothycarambat commented on GitHub (Oct 21, 2024):

Correct, this is only limited to the swagger UI, not the functionality of the endpoint itself.

@timothycarambat commented on GitHub (Oct 21, 2024): Correct, this is only limited to the swagger UI, not the functionality of the endpoint itself.
Author
Owner

@uu-kt commented on GitHub (Feb 13, 2025):

您好 ,现在测试API接口文档的文件上传功能,发现单一文件可以上传成功,但是批量上传文件就是报错,是现有的API不完善吗,还是我的参数传输存在错误?

@uu-kt commented on GitHub (Feb 13, 2025): 您好 ,现在测试API接口文档的文件上传功能,发现单一文件可以上传成功,但是批量上传文件就是报错,是现有的API不完善吗,还是我的参数传输存在错误?
yindo changed title from [DOC]: Try Swagger API POST /v1/document/upload - fails to upload multipart file to [GH-ISSUE #2473] [DOC]: Try Swagger API POST /v1/document/upload - fails to upload multipart file 2026-06-05 14:41:41 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#1606