{"record":{"id":"34e909c7ef915279","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-run-id-but-receiv","errorCode":null,"errorMessage":"Expected a non-empty value for `run_id` but received {run_id!r}","messagePattern":"Expected a non-empty value for `run_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/beta/threads/runs/runs.py","lineNumber":642,"sourceCode":"        extra_body: Body | None = None,\n        timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n    ) -> Run:\n        \"\"\"\n        Retrieves a run.\n\n        Args:\n          extra_headers: Send extra headers\n\n          extra_query: Add additional query parameters to the request\n\n          extra_body: Add additional JSON properties to the request\n\n          timeout: Override the client-level default timeout for this request, in seconds\n        \"\"\"\n        if not thread_id:\n            raise ValueError(f\"Expected a non-empty value for `thread_id` but received {thread_id!r}\")\n        if not run_id:\n            raise ValueError(f\"Expected a non-empty value for `run_id` but received {run_id!r}\")\n        extra_headers = {\"OpenAI-Beta\": \"assistants=v2\", **(extra_headers or {})}\n        return self._get(\n            path_template(\"/threads/{thread_id}/runs/{run_id}\", thread_id=thread_id, run_id=run_id),\n            options=make_request_options(\n                extra_headers=extra_headers,\n                extra_query=extra_query,\n                extra_body=extra_body,\n                timeout=timeout,\n                security={\"bearer_auth\": True},\n            ),\n            cast_to=Run,\n        )\n\n    @typing_extensions.deprecated(\"The Assistants API is deprecated in favor of the Responses API\")\n    def update(\n        self,\n        run_id: str,\n        *,","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/threads/runs/runs.py#L624-L660","documentation":"The sync Runs.retrieve() method validates that `run_id` is a non-empty string (checked after `thread_id`). An empty, None, or falsy value raises ValueError before any request is sent.","triggerScenarios":"Calling `client.beta.threads.runs.retrieve(thread_id=\"thread_...\", run_id=\"\")` or polling with a run variable whose id is empty/None.","commonSituations":"Passing a Run object instead of `run.id`; polling before the create call returned (racing); run id lost during persistence/serialization between jobs.","solutions":["Pass `run.id` from the created run object","Ensure the create call completed and returned before polling","Persist and reload both thread_id and run_id together"],"exampleFix":"// before\nretrieved = client.beta.threads.runs.retrieve(thread_id=thread_id, run_id=\"\")\n\n// after\ncreated = client.beta.threads.runs.create(thread_id=thread_id, assistant_id=assistant_id)\nretrieved = client.beta.threads.runs.retrieve(thread_id=thread_id, run_id=created.id)","handlingStrategy":"validation","validationCode":"if not run_id:\n    raise ValueError(\"run_id is required to retrieve a run\")","typeGuard":"def is_valid_run_id(run_id: object) -> bool:\n    return isinstance(run_id, str) and run_id.startswith(\"run_\")","tryCatchPattern":"try:\n    run = client.beta.threads.runs.retrieve(thread_id=thread_id, run_id=run_id)\nexcept ValueError as e:\n    logging.warning(\"invalid run_id: %s\", e)\n    raise","preventionTips":["Use `run.id`, not the Run object","Await/complete create before polling","Type-check run ids (`run_` prefix)"],"tags":["assistants","threads","runs","polling","validation","valueerror"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}