{"record":{"id":"8eda925a6359dbf7","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-step-id-but-recei","errorCode":null,"errorMessage":"Expected a non-empty value for `step_id` but received {step_id!r}","messagePattern":"Expected a non-empty value for `step_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/beta/threads/runs/steps.py","lineNumber":88,"sourceCode":"\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            ),\n            cast_to=RunStep,\n        )","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/threads/runs/steps.py#L70-L106","documentation":"`steps.retrieve` validates `step_id` (third and last check) and raises this ValueError when it is falsy. The step ID (e.g. `step_abc123`) is required to address an individual run step resource.","triggerScenarios":"Calling retrieve with `step_id=None`/`\"\"` — e.g. iterating `run.steps` but passing the whole step object or an uninitialized variable instead of `step.id`.","commonSituations":"Confusing the step object with its ID, parsing step IDs from webhook/event payloads where the field is absent, or off-by-one logic producing an empty value.","solutions":["Pass `step.id` from the step object you obtained via listing or events","Validate the step_id string is non-empty before retrieving","When parsing events, default to skipping the call if the field is missing"],"exampleFix":"# before\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id, step_id=step)  # step is an object/None\n\n# after\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id, step_id=step.id)","handlingStrategy":"type-guard","validationCode":"step_id = step.id if hasattr(step, \"id\") else step\nif not isinstance(step_id, str) or not step_id:\n    raise ValueError(\"step_id must be a non-empty string\")\nstep = client.beta.threads.runs.steps.retrieve(thread_id=thread_id, run_id=run_id, step_id=step_id)","typeGuard":"def is_valid_step_id(value: object) -> TypeGuard[str]:\n    return isinstance(value, str) and value.startswith(\"step_\")","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 \"step_id\" in str(e):\n        continue  # skip malformed references when iterating\n    raise","preventionTips":["Always pass step.id, not the RunStep object","Skip lookups when event payloads lack a step ID","Normalize object-vs-id handling in helper functions"],"tags":["python","openai","assistants","run-steps","step-id","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}