{"record":{"id":"9f1b232d3a7648ea","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-thread-id-but-rec-9f1b23","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/steps.py","lineNumber":84,"sourceCode":"        Args:\n          include: A list of additional fields to include in the response. Currently the only\n              supported value is `step_details.tool_calls[*].file_search.results[*].content`\n              to fetch the file search result content.\n\n              See the\n              [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)\n              for more information.\n\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        if not step_id:\n            raise ValueError(f\"Expected a non-empty value for `step_id` but received {step_id!r}\")\n        extra_headers = {\"OpenAI-Beta\": \"assistants=v2\", **(extra_headers or {})}\n        return self._get(\n            path_template(\n                \"/threads/{thread_id}/runs/{run_id}/steps/{step_id}\",\n                thread_id=thread_id,\n                run_id=run_id,\n                step_id=step_id,\n            ),\n            options=make_request_options(\n                extra_headers=extra_headers,\n                extra_query=extra_query,\n                extra_body=extra_body,\n                timeout=timeout,\n                query=maybe_transform({\"include\": include}, step_retrieve_params.StepRetrieveParams),","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/threads/runs/steps.py#L66-L102","documentation":"`client.beta.threads.runs.steps.retrieve(thread_id, run_id, step_id)` requires a non-empty `thread_id` as the first of three validated path parameters for `/threads/{thread_id}/runs/{run_id}/steps/{step_id}`. A falsy value raises this ValueError client-side with no HTTP request.","triggerScenarios":"Fetching a run step detail while the thread ID variable is None/empty — often when iterating steps from a listing but constructing the retrieve call with an incomplete context object.","commonSituations":"Storing step references without their parent thread/run IDs, or copying example code and forgetting to substitute the thread ID.","solutions":["Keep the full (thread_id, run_id, step_id) triple together when storing step references","Validate all three IDs before calling retrieve","Re-derive missing IDs from the run/thread you originally listed"],"exampleFix":"# before\nstep = client.beta.threads.runs.steps.retrieve(thread_id=None, run_id=run_id, step_id=step_id)\n\n# after\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread.id, run_id=run.id, step_id=step_id)","handlingStrategy":"validation","validationCode":"if not (thread_id and run_id and step_id):\n    raise ValueError(f\"need thread/run/step ids, got {thread_id!r} {run_id!r} {step_id!r}\")\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id, step_id=step_id)","typeGuard":"def is_step_ref(triple: tuple) -> TypeGuard[tuple[str, str, str]]:\n    t, r, s = triple\n    return all(isinstance(x, str) and x for x in (t, r, s))","tryCatchPattern":"try:\n    step = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id, step_id=step_id)\nexcept ValueError as e:\n    logger.error(\"invalid step reference: %s\", e)\n    raise","preventionTips":["Store step references as (thread_id, run_id, step_id) triples","Validate all three IDs in one guard before calling","Don't persist step IDs detached from their parents"],"tags":["python","openai","assistants","run-steps","thread-id","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}