{"record":{"id":"6cb83637696d22be","repo":"microsoft/graphrag","slug":"request-id-needs-to-be-passed-as-a-keyword-argumen","errorCode":null,"errorMessage":"request_id needs to be passed as a keyword argument","messagePattern":"request_id needs to be passed as a keyword argument","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-llm/graphrag_llm/threading/completion_thread_runner.py","lineNumber":210,"sourceCode":"        callback: ThreadedLLMCompletionResponseHandler,\n    ):\n        while True and not quit_process_event.is_set():\n            try:\n                data = output_queue.get(timeout=1)\n            except Empty:\n                continue\n            if data is None:\n                break\n            request_id, response = data\n            response = callback(request_id, response)\n\n            if asyncio.iscoroutine(response):\n                response = asyncio.run(response)\n\n    def _process_input(request_id: str, **kwargs: Unpack[\"LLMCompletionArgs\"]):\n        if not request_id:\n            msg = \"request_id needs to be passed as a keyword argument\"\n            raise ValueError(msg)\n        input_queue.put((request_id, kwargs))\n\n    handle_response_thread = threading.Thread(\n        target=_process_output,\n        args=(quit_process_event, output_queue, response_handler),\n    )\n    handle_response_thread.start()\n\n    def _cleanup():\n        for _ in threads:\n            input_queue.put(None)\n\n        for thread in threads:\n            while thread.is_alive():\n                thread.join(timeout=1)\n\n        output_queue.put(None)\n","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-llm/graphrag_llm/threading/completion_thread_runner.py#L192-L228","documentation":"CompletionThreadRunner's _process_input helper requires a truthy request_id keyword so each completion request can be correlated with its response via the internal queue. Calling it without request_id (or with an empty string) raises ValueError immediately.","triggerScenarios":"Invoking the runner's returned input function with only LLMCompletionArgs kwargs and no request_id, e.g. runner(input='hello') instead of runner(request_id='abc', input='hello').","commonSituations":"Migrating synchronous code that called a plain completion function, wrapping the runner in an adapter that forwards **kwargs but drops request_id, or generating request_ids that are sometimes empty strings.","solutions":["Pass a unique non-empty request_id keyword argument on every call","If forwarding kwargs from another layer, thread request_id through the call chain explicitly","Generate ids via uuid4().hex if you don't have a natural correlation id"],"exampleFix":"# before\nrunner(input=\"Summarize this\", model=\"gpt-4\")\n\n# after\nrunner(request_id=\"job-42-item-7\", input=\"Summarize this\", model=\"gpt-4\")","handlingStrategy":"validation","validationCode":"request_id = request_id or uuid.uuid4().hex\nassert request_id, \"request_id required\"\nrunner(request_id=request_id, **kwargs)","typeGuard":"null","tryCatchPattern":"try:\n    runner(request_id=rid, **kwargs)\nexcept ValueError as e:\n    if 'request_id' in str(e):\n        rid = uuid.uuid4().hex\n        runner(request_id=rid, **kwargs)\n    else:\n        raise","preventionTips":["Always generate request_id first: rid = uuid4().hex","In wrapper layers, make request_id an explicit named parameter rather than absorbed **kwargs"],"tags":["threading","request-id","validation","graphrag"],"backgroundTag":"missing-required-keyword-argument","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}