Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, and more.
https://anythingllm.com
MIT License
24.89k stars 2.52k forks source link

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

Open appdevhm88mt opened 6 days ago

appdevhm88mt commented 6 days ago

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

timothycarambat commented 6 days ago
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?

appdevhm88mt commented 20 hours ago

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

timothycarambat commented 6 hours ago

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