OpenBMB/ChatDev · error · HTTPException

log_level must be either DEBUG or INFO

Error message

log_level must be either DEBUG or INFO

What it means

The batch endpoint tries to convert the log_level string to a LogLevel enum; on ValueError it returns 400. Given the message, only DEBUG and INFO are accepted here.

Source

Thrown at server/routes/batch.py:41

        manager = ensure_known_session(session_id, require_connection=True)
    except ValidationError as exc:
        raise HTTPException(status_code=400, detail=str(exc))

    if max_parallel < 1:
        raise HTTPException(status_code=400, detail="max_parallel must be >= 1")

    try:
        content = await file.read()
        tasks, file_base = parse_batch_file(content, file.filename or "batch.csv")
    except ValidationError as exc:
        raise HTTPException(status_code=400, detail=str(exc))

    resolved_level = None
    if log_level:
        try:
            resolved_level = LogLevel(log_level)
        except ValueError:
            raise HTTPException(status_code=400, detail="log_level must be either DEBUG or INFO")

    service = BatchRunService()
    asyncio.create_task(
        service.run_batch(
            session_id,
            yaml_file,
            tasks,
            manager,
            max_parallel=max_parallel,
            file_base=file_base,
            log_level=resolved_level,
        )
    )

    return {
        "status": "accepted",
        "session_id": session_id,
        "batch_id": session_id,

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Use DEBUG or INFO (exact case as defined in the LogLevel enum)
  2. Omit log_level entirely if you don't need to override it
  3. Check the LogLevel enum definition for accepted values before sending

Example fix

# before
log_level: WARNING
# after
log_level: INFO
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {'DEBUG', 'INFO'}
if log_level is not None:
    assert log_level in ALLOWED, f'log_level must be one of {ALLOWED}'

Type guard

def is_valid_batch_level(v: str | None) -> bool:
    return v is None or v in {'DEBUG', 'INFO'}

Try / catch

try:
    client.execute_batch(..., log_level=level)
except HTTPError as e:
    if e.response.status_code == 400 and 'log_level' in e.response.text:
        client.execute_batch(..., log_level='INFO')

Prevention

When it happens

Trigger: POST to batch execution with log_level=WARNING, TRACE, 'debug' (wrong case depends on enum), or any string not in the LogLevel enum.

Common situations: Copy-pasting log levels from other tooling (WARNING, ERROR) that this endpoint doesn't accept; case mismatches; stale config from an older API that allowed more levels.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/0a5a8152d150ab8a. Report an issue: GitHub.