{"record":{"id":"1cdc66bb1f7faf9c","repo":"OpenBMB/ChatDev","slug":"log-level-must-be-one-of-debug-info-warning-err","errorCode":null,"errorMessage":"log_level must be one of DEBUG, INFO, WARNING, ERROR, CRITICAL","messagePattern":"log_level must be one of DEBUG, INFO, WARNING, ERROR, CRITICAL","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"server/routes/execute_sync.py","lineNumber":159,"sourceCode":"        \"token_usage\": token_usage,\n        \"output_dir\": graph_context.directory,\n    }\n    return final_message, meta\n\n\ndef _sse_event(event_type: str, data: Any) -> str:\n    payload = json.dumps(data, ensure_ascii=False, default=str)\n    return f\"event: {event_type}\\ndata: {payload}\\n\\n\"\n\n\n@router.post(\"/api/workflow/run\")\nasync def run_workflow_sync(request: WorkflowRunRequest, http_request: Request):\n    try:\n        resolved_log_level: Optional[LogLevel] = None\n        if request.log_level:\n            resolved_log_level = LogLevel(request.log_level)\n    except ValueError:\n        raise HTTPException(\n            status_code=400,\n            detail=\"log_level must be one of DEBUG, INFO, WARNING, ERROR, CRITICAL\",\n        )\n\n    accepts_stream = _SSE_CONTENT_TYPE in (http_request.headers.get(\"accept\") or \"\")\n    if not accepts_stream:\n        try:\n            result = await run_in_threadpool(\n                run_workflow,\n                request.yaml_file,\n                task_prompt=request.task_prompt,\n                attachments=request.attachments,\n                session_name=request.session_name,\n                variables=request.variables,\n                log_level=resolved_log_level,\n            )\n        except FileNotFoundError as exc:\n            raise HTTPException(status_code=404, detail=str(exc))","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/server/routes/execute_sync.py#L141-L177","documentation":"run_workflow_sync converts request.log_level to the LogLevel enum; a ValueError yields HTTP 400 with the accepted list. Unlike the async/batch endpoints, this endpoint documents the full set DEBUG, INFO, WARNING, ERROR, CRITICAL.","triggerScenarios":"POST to the sync workflow endpoint with log_level values like TRACE, FINE, lowercase variants not accepted by the enum, or arbitrary strings.","commonSituations":"Reusing log level strings from Python logging or log4j conventions that don't map to this enum; case sensitivity mismatches.","solutions":["Use one of DEBUG, INFO, WARNING, ERROR, CRITICAL exactly as cased in the LogLevel enum","Omit log_level to use the server default","Normalize log level strings client-side against the accepted list before sending"],"exampleFix":"# before\n\"log_level\": \"trace\"\n# after\n\"log_level\": \"DEBUG\"","handlingStrategy":"validation","validationCode":"LEVELS = {'DEBUG','INFO','WARNING','ERROR','CRITICAL'}\nif log_level is not None:\n    assert log_level in LEVELS, f'log_level must be one of {LEVELS}'","typeGuard":"def is_valid_level(v: str | None) -> bool:\n    return v is None or v in {'DEBUG','INFO','WARNING','ERROR','CRITICAL'}","tryCatchPattern":"except HTTPError as e:\n    if e.response.status_code == 400 and 'log_level' in e.response.text:\n        req['log_level'] = 'INFO'; client.run(req)","preventionTips":["Match enum casing exactly (uppercase)","Omit log_level to use the default rather than guessing"],"tags":["http-400","logging","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}