{"record":{"id":"fef3fdd3aecc47de","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-thread-id-but-rec-fef3fd","errorCode":null,"errorMessage":"Expected a non-empty value for `thread_id` but received {thread_id!r}","messagePattern":"Expected a non-empty value for `thread_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/beta/threads/runs/runs.py","lineNumber":574,"sourceCode":"        model: Union[str, ChatModel, None] | Omit = omit,\n        parallel_tool_calls: bool | Omit = omit,\n        reasoning_effort: Optional[ReasoningEffort] | Omit = omit,\n        response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,\n        stream: Optional[Literal[False]] | Literal[True] | Omit = omit,\n        temperature: Optional[float] | Omit = omit,\n        tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,\n        tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,\n        top_p: Optional[float] | Omit = omit,\n        truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,\n        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.\n        # The extra values given here take precedence over values defined on the client or passed to this method.\n        extra_headers: Headers | None = None,\n        extra_query: Query | None = None,\n        extra_body: Body | None = None,\n        timeout: float | httpx2.Timeout | None | NotGiven = not_given,\n    ) -> Run | Stream[AssistantStreamEvent]:\n        if not thread_id:\n            raise ValueError(f\"Expected a non-empty value for `thread_id` but received {thread_id!r}\")\n        extra_headers = {\"OpenAI-Beta\": \"assistants=v2\", **(extra_headers or {})}\n        return self._post(\n            path_template(\"/threads/{thread_id}/runs\", thread_id=thread_id),\n            body=maybe_transform(\n                {\n                    \"assistant_id\": assistant_id,\n                    \"additional_instructions\": additional_instructions,\n                    \"additional_messages\": additional_messages,\n                    \"instructions\": instructions,\n                    \"max_completion_tokens\": max_completion_tokens,\n                    \"max_prompt_tokens\": max_prompt_tokens,\n                    \"metadata\": metadata,\n                    \"model\": model,\n                    \"parallel_tool_calls\": parallel_tool_calls,\n                    \"reasoning_effort\": reasoning_effort,\n                    \"response_format\": response_format,\n                    \"stream\": stream,\n                    \"temperature\": temperature,","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/threads/runs/runs.py#L556-L592","documentation":"The sync Runs.create() method requires a non-empty `thread_id`. The SDK raises ValueError before POSTing to /threads/{thread_id}/runs if the value is empty, None, or falsy.","triggerScenarios":"Calling `client.beta.threads.runs.create(thread_id=\"\", assistant_id=\"asst_...\")`, or passing an undefined/None thread variable when starting a run.","commonSituations":"Running an assistant on a thread that was never created; thread id lost between functions or tasks; using an empty string as a placeholder in scaffolding code.","solutions":["Create the thread first and pass `thread.id` to the run","Validate `thread_id` is a non-empty string before creating the run","If the id arrives from user input or a queue, validate it at ingestion"],"exampleFix":"// before\nrun = client.beta.threads.runs.create(thread_id=\"\", assistant_id=assistant_id)\n\n// after\nthread = client.beta.threads.create()\nrun = client.beta.threads.runs.create(thread_id=thread.id, assistant_id=assistant_id)","handlingStrategy":"validation","validationCode":"if not thread_id:\n    raise ValueError(\"thread_id is required to create a run\")","typeGuard":"def is_valid_thread_id(thread_id: object) -> bool:\n    return isinstance(thread_id, str) and bool(thread_id.strip())","tryCatchPattern":"try:\n    run = client.beta.threads.runs.create(thread_id=thread_id, assistant_id=assistant_id)\nexcept ValueError as e:\n    logging.error(\"cannot start run: %s\", e)\n    raise","preventionTips":["Create the thread before the run in the same function","Pass ids explicitly between functions","Reject empty thread ids at input boundaries"],"tags":["assistants","threads","runs","validation","valueerror"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}