{"record":{"id":"9385d2a7bdcf19d3","repo":"CopilotKit/CopilotKit","slug":"key-is-required","errorCode":null,"errorMessage":"{key} is required","messagePattern":"(.+?) is required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"sdk-python/copilotkit/integrations/fastapi.py","lineNumber":73,"sourceCode":"            future = loop.run_in_executor(executor, run_handler_in_thread, request, sdk)\n            return await future\n        return await handler(request, sdk)\n\n    # Ensure the prefix starts with a slash and remove trailing slashes\n    normalized_prefix = \"/\" + prefix.strip(\"/\")\n\n    fastapi_app.add_api_route(\n        f\"{normalized_prefix}/{{path:path}}\",\n        make_handler,\n        methods=[\"GET\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\"],\n    )\n\n\ndef body_get_or_raise(body: Any, key: str):\n    \"\"\"Get value from body or raise an error\"\"\"\n    value = body.get(key)\n    if value is None:\n        raise HTTPException(status_code=400, detail=f\"{key} is required\")\n    return value\n\n\nasync def handler(request: Request, sdk: CopilotKitRemoteEndpoint):\n    \"\"\"Handle FastAPI request\"\"\"\n\n    try:\n        body = await request.json()\n    except:  # pylint: disable=bare-except\n        body = None\n\n    # Propagate x-aimock-* headers to outgoing LLM calls via ContextVar\n    set_forwarded_headers(dict(request.headers))\n\n    path = request.path_params.get(\"path\")\n    method = request.method\n    context = cast(\n        CopilotKitContext,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/CopilotKit/CopilotKit/blob/68fbe97d87420bd84e8196965c71bd6e394a3f7a/sdk-python/copilotkit/integrations/fastapi.py#L55-L91","documentation":"Error \"{key} is required\" thrown in CopilotKit/CopilotKit.","triggerScenarios":"Thrown at sdk-python/copilotkit/integrations/fastapi.py:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"68fbe97d87420bd84e8196965c71bd6e394a3f7a","analyzedAt":"2026-08-27T04:03:26.537Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}