fix(api): group create read product from multipart form (bug: 'provide product info' when no file attached)
The GroupBuilder sends the create form as multipart/form-data (FormData). The code decided JSON vs form by checking — when no file was attached, request.files was empty/falsy, so it tried get_json() on a multipart body and lost the product field -> 400 'provide product info' even though the user filled the product name. Fix: branch on the Content-Type (multipart/form-data -> request.form) instead of request.files. Added a regression test (multipart create with product only -> 201). Verified live: multipart product-only create now returns 201.
This commit is contained in:
@@ -88,7 +88,10 @@ def create_group():
|
||||
file.save(dest)
|
||||
saved_files.append(dest.name)
|
||||
|
||||
data = request.form.to_dict() if request.files else (request.get_json(silent=True) or {})
|
||||
if request.content_type and "multipart/form-data" in request.content_type:
|
||||
data = request.form.to_dict()
|
||||
else:
|
||||
data = request.get_json(silent=True) or {}
|
||||
|
||||
from ..services.file_parser import parse_document
|
||||
|
||||
|
||||
Reference in New Issue
Block a user