sgl-project/sglang · error · HTTPException
{detail}
Error message
{detail} What it means
Generic HTTP 400 wrapper: create_action_generation catches any ValueError from request parsing or generation-prep (response_format, extra_params, cosmos3 observation/prompt validation, sampling params) and re-raises it as HTTPException(400, detail=str(exc)). The detail text identifies the underlying validation failure.
Source
Thrown at python/sglang/multimodal_gen/runtime/entrypoints/action/api.py:228
payload = await _multipart_action_payload(request, uploads_dir)
elif "msgpack" in content_type:
payload = unpack_msgpack(await request.body())
else:
payload = await request.json()
wants_msgpack = _wants_msgpack(request)
if wants_msgpack:
_prefer_numpy_output(payload)
output = await infer_action(payload, server_args)
if _response_format(payload) == "raw":
response = action_raw_response(output, preserve_numpy=wants_msgpack)
else:
response = action_generation_response(
output,
server_args,
preserve_numpy=wants_msgpack,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
if wants_msgpack:
return Response(
content=pack_msgpack(response), media_type="application/msgpack"
)
return orjson_response(response)
@router.get("/metadata")
async def action_metadata_endpoint(request: Request):
return orjson_response(action_metadata(request.app.state.server_args))
@router.websocket("/realtime")
async def action_realtime_ws(websocket: WebSocket):
server_args: ServerArgs = websocket.app.state.server_args
await run_action_msgpack_ws(
websocket,
server_args,View on GitHub (pinned to 0132848349)
Solutions
- Read the detail field in the 400 response; it re-states the specific ValueError message (e.g. image dtype, JSON parse)
- Fix the flagged field per that specific message
- Re-send with a minimal known-good payload first, then add fields back to isolate the offending one
Defensive patterns
Strategy: try-catch
Try / catch
try:
resp = requests.post(ACTION_URL, json=payload, timeout=30)
resp.raise_for_status()
except requests.HTTPError:
detail = resp.json().get("detail", "")
logger.warning("action request rejected: %s", detail)
# detail names the exact offending field; fix and retry once Prevention
- Log and surface the 400 detail message — it pinpoints the bad field
- Build requests with a shared, tested client helper
- Smoke-test payloads against a dev endpoint before production
When it happens
Trigger: Any malformed action-generation request: bad runtime.response_format, invalid extra_params JSON, wrong image dtype/shape, bad prompt type, or invalid sampling parameters.
Common situations: Client-side payload construction bugs; integration testing against the action endpoint with improperly formatted observations or params.
Related errors
- runtime.response_format must be 'envelope' or 'raw'
- {field_name} is not valid JSON
- {field_name} must be a JSON object
- Invalid request body: {e}
- cache_dit_params must be a dict, got {type(raw).__name__}.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/0f9eedcbdc191ff1.
Report an issue: GitHub.