-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Contact Information
MaxKB Version
v1.10.x (latest Docker image)
Problem Description
When uploading a file to the knowledge base document endpoint without all required fields (e.g., missing the document type field), the API returns {"code": 500} with message 文档类型:该字段必须填写 instead of a proper 400 Bad Request. Missing required fields are a client-side input error and should return a 4xx status code, not 5xx.
Steps to Reproduce
Upload a file without specifying the required "type" field
curl -s -X POST
-H "Authorization: Bearer <your_token>"
-F "file=@test.pdf"
http://localhost:8080/admin/api/workspace/default/knowledge/<your_kb_id>/document
The expected correct result
{"code": 400, "message": "文档类型:该字段必须填写", "data": null}
Related log output
{"code": 500, "message": "文档类型:该字段必须填写", "data": null}Additional Information
Tested with 32 different file types (PDF, DOCX, XLSX, MD, TXT, HTML - including empty files, corrupted files, oversized files), all return the same code 500 response. Suggest validating required fields before processing the upload and returning 400 Bad Request.