{"record":{"id":"d5a7e08ab80bca52","repo":"sgl-project/sglang","slug":"invalid-request-body-e","errorCode":null,"errorMessage":"Invalid request body: {e}","messagePattern":"Invalid request body: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/openai/mesh_api.py","lineNumber":205,"sourceCode":"        try:\n            body = await request.json()\n        except Exception:\n            body = {}\n        try:\n            payload: Dict[str, Any] = dict(body or {})\n\n            if payload.get(\"input_image\"):\n                img_src = payload.pop(\"input_image\")\n                uploads_dir = os.path.join(\"outputs\", \"uploads\")\n                os.makedirs(uploads_dir, exist_ok=True)\n                input_path = await save_image_to_path(\n                    img_src,\n                    os.path.join(uploads_dir, f\"{request_id}_input_image\"),\n                )\n\n            req = MeshGenerationsRequest(**payload)\n        except Exception as e:\n            raise HTTPException(status_code=400, detail=f\"Invalid request body: {e}\")\n\n    if not input_path:\n        raise HTTPException(\n            status_code=422,\n            detail=\"An input image is required for mesh generation\",\n        )\n\n    sampling_params = _build_sampling_params_from_request(request_id, req, input_path)\n    job = _mesh_job_from_sampling(request_id, req, sampling_params)\n    await MESH_STORE.upsert(request_id, job)\n\n    batch = prepare_request(\n        server_args=server_args,\n        sampling_params=sampling_params,\n    )\n\n    asyncio.create_task(_dispatch_job_async(request_id, batch))\n    return MeshResponse(**job)","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/openai/mesh_api.py#L187-L223","documentation":"Thrown when constructing MeshGenerationsRequest from the request body fails, or when saving an inline/base64 image source raised. Any exception inside the body-parsing block (including image saving) is converted to HTTP 400 'Invalid request body'.","triggerScenarios":"POST /mesh/generations with a JSON body missing required fields, wrong field types, unknown keys rejected by the Pydantic model, or a malformed image source reference.","commonSituations":"Sending extra parameters the model doesn't define; passing a non-string model id; typo'd field names like 'promt'; using an API version whose request schema changed.","solutions":["Validate the request body against the MeshGenerationsRequest schema (required fields, types) before sending","Check the endpoint's request model definition for required vs optional fields","Ensure the image field (file or source) is provided in the accepted form"],"exampleFix":"// before\n{\"model\": \"mesh-model\", \"prompt\": 123}\n// after\n{\"model\": \"mesh-model\", \"prompt\": \"generate 3d mesh\"}","handlingStrategy":"validation","validationCode":"# client-side: check required fields before POST\nassert isinstance(body.get('model'), str) and body.get('model')\nassert isinstance(body.get('prompt', 'generate 3d mesh'), str)","typeGuard":null,"tryCatchPattern":"if resp.status_code == 400 and 'Invalid request body' in detail:\n    log(resp.text); fix schema per MeshGenerationsRequest","preventionTips":["Mirror MeshGenerationsRequest fields in client types","Log full detail message — it includes the Pydantic error"],"tags":["http","request-validation","pydantic","mesh-generation"],"backgroundTag":"request-body-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}