sgl-project/sglang · error · HTTPException
Failed to process image source: {str(e)}
Error message
Failed to process image source: {str(e)} What it means
Raised by the mesh generation endpoint when saving the uploaded image to the server's uploads directory fails. The endpoint wraps save_image_to_path in a try/except and converts any exception (I/O error, invalid file object, unwritable directory) into an HTTP 400 with the underlying message.
Source
Thrown at python/sglang/multimodal_gen/runtime/entrypoints/openai/mesh_api.py:170
urls = url or url_array
image_list = merge_image_input_list(images, urls)
if not image_list:
raise HTTPException(
status_code=422,
detail="Field 'image' or 'url' is required for mesh generation",
)
uploads_dir = os.path.join("outputs", "uploads")
os.makedirs(uploads_dir, exist_ok=True)
img = image_list[0]
filename = img.filename if hasattr(img, "filename") else "input_image"
try:
input_path = await save_image_to_path(
img, os.path.join(uploads_dir, f"{request_id}_{filename}")
)
except Exception as e:
raise HTTPException(
status_code=400, detail=f"Failed to process image source: {str(e)}"
)
req = MeshGenerationsRequest(
prompt=prompt or "generate 3d mesh",
model=model,
seed=seed,
generator_device=generator_device,
num_inference_steps=num_inference_steps,
negative_prompt=negative_prompt,
output_format=output_format,
**(
{"guidance_scale": guidance_scale} if guidance_scale is not None else {}
),
)
else:
try:
body = await request.json()View on GitHub (pinned to 0132848349)
Solutions
- Verify the uploaded file is a valid image (open it client-side before sending)
- Check the server's uploads directory exists and is writable by the server process
- Retry with a smaller/standard format (PNG/JPEG) image to rule out decode issues
Example fix
// before
files = {"image": ("mesh.txt", open("mesh.txt","rb"), "text/plain")}
// after
files = {"image": ("input.png", open("input.png","rb"), "image/png")} Defensive patterns
Strategy: try-catch
Validate before calling
from PIL import Image img = Image.open(path); img.verify() # raises if not a valid image
Try / catch
try:
resp = await client.post('/v1/mesh/generations', files=files)
except httpx.HTTPStatusError as e:
if e.response.status_code == 400 and 'image source' in e.response.text:
# re-encode image and retry once
... Prevention
- Validate images client-side before upload
- Ensure server uploads dir is writable in deployment
When it happens
Trigger: POST to the mesh generations endpoint with a multipart image that cannot be read/saved: corrupted UploadFile stream, missing uploads directory, or filesystem permission errors on the server.
Common situations: Server container running as non-root without write access to the uploads dir; client sending a non-file field where an image is expected; disk full.
Related errors
- Invalid request body: {e}
- An input image is required for mesh generation
- Mesh not found
- Mesh has been uploaded to cloud storage. Please use the clou
- Generation is still in-progress
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/c275169fdb64d4ff.
Report an issue: GitHub.