openai/openai-python · error · ValueError
Expected a non-empty value for `run_id` but received {run_id
Error message
Expected a non-empty value for `run_id` but received {run_id!r} What it means
The sync EvalRunOutputItem.retrieve() method requires run_id to be non-empty because it is interpolated into the request path /evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}. An empty or None run_id would yield a malformed URL, so the SDK raises ValueError before any network call.
Source
Thrown at src/openai/resources/evals/runs/output_items.py:74
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> OutputItemRetrieveResponse:
"""
Get an evaluation run output item by ID.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not eval_id:
raise ValueError(f"Expected a non-empty value for `eval_id` but received {eval_id!r}")
if not run_id:
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
if not output_item_id:
raise ValueError(f"Expected a non-empty value for `output_item_id` but received {output_item_id!r}")
return self._get(
path_template(
"/evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}",
eval_id=eval_id,
run_id=run_id,
output_item_id=output_item_id,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"bearer_auth": True},
),
cast_to=OutputItemRetrieveResponse,
)View on GitHub (pinned to 9917c6e28e)
Solutions
- Verify run_id is set to the id of an existing eval run (created via client.evals.runs.create).
- Log or debug-print run_id right before the call to confirm its value.
- If it comes from storage, add a check for missing/empty values at load time.
- Guard with: if not run_id: raise ValueError('run_id is required').
Example fix
// before
item = client.evals.runs.output_items.retrieve(eval_id=eval_id, run_id=run_id, output_item_id=output_item_id)
// after
if not run_id:
raise ValueError(f"run_id is required, got {run_id!r}")
item = client.evals.runs.output_items.retrieve(eval_id=eval_id, run_id=run_id, output_item_id=output_item_id) Defensive patterns
Strategy: validation
Validate before calling
if not isinstance(run_id, str) or not run_id.strip():
raise ValueError(f"run_id must be a non-empty string, got {run_id!r}") Type guard
def is_valid_run_id(run_id: object) -> bool:
return isinstance(run_id, str) and bool(run_id.strip()) Try / catch
try:
item = client.evals.runs.output_items.retrieve(eval_id=eval_id, run_id=run_id, output_item_id=output_item_id)
except ValueError as e:
if 'run_id' in str(e):
raise ValueError(f'Skipping retrieve: {e}') from e
raise Prevention
- Store run ids immediately after creating runs.
- Treat a failed run-creation call as fatal before using its would-be id.
- Skip loop entries with falsy ids.
When it happens
Trigger: Calling client.evals.runs.output_items.retrieve() with run_id='' or None while eval_id is valid. Common when run_id is stored from a previous run but the run creation failed or returned no id.
Common situations: Run id fetched from client.evals.runs.create(...) whose response lacked an id, ids read from a database/CSV with empty cells, or variables shadowed/typo'd so run_id is never assigned.
Related errors
- Expected a non-empty value for `eval_id` but received {eval_
- Expected a non-empty value for `output_item_id` but received
- Expected a non-empty value for `eval_id` but received {eval_
- Expected a non-empty value for `run_id` but received {run_id
- Expected a non-empty value for `group_id` but received {grou
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/f7c02dc299bdac13.
Report an issue: GitHub.