{"record":{"id":"21cb88e5e6edeff4","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-run-id-but-receiv-21cb88","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/steps.py","lineNumber":86,"sourceCode":"              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),\n                security={\"bearer_auth\": True},\n            ),","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/threads/runs/steps.py#L68-L104","documentation":"`steps.retrieve` validates `run_id` (second check) and raises this ValueError when it is falsy, because the run ID is required in the step retrieval path. The check happens before any network activity.","triggerScenarios":"Retrieving a run step with `run_id=None` or `\"\"` — commonly when only the step ID was persisted, or the run variable was overwritten in a loop.","commonSituations":"Crawling steps from logs where only step IDs were recorded, or variable shadowing (`run` reused for iterations) leaving the wrong value in scope.","solutions":["Persist the run ID with every step ID you intend to fetch later","Validate `run_id` before the call","Avoid reusing variable names across loop iterations when building SDK calls"],"exampleFix":"# before\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=last_run, step_id=\"step_abc\")  # last_run overwritten to None\n\n# after\nrun_id_to_use = run.id\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id_to_use, step_id=\"step_abc\")","handlingStrategy":"validation","validationCode":"if not run_id:\n    raise ValueError(\"run_id required to retrieve a run step\")\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id, step_id=step_id)","typeGuard":"def is_valid_run_id(value: object) -> TypeGuard[str]:\n    return isinstance(value, str) and value.startswith(\"run_\")","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    if \"run_id\" in str(e):\n        logger.warning(\"step lookup skipped: run id missing\")\n    else:\n        raise","preventionTips":["Avoid variable shadowing of run objects in loops","Persist run IDs alongside step IDs","Validate references loaded from external stores"],"tags":["python","openai","assistants","run-steps","run-id","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}