openai/openai-python · error · ValueError
Expected a non-empty value for `container_id` but received {
Error message
Expected a non-empty value for `container_id` but received {container_id!r} What it means
Containers.retrieve (sync) requires a truthy container_id for GET /containers/{container_id}. Client-side validation of required path parameters; ValueError is raised for None/empty values without any HTTP request.
Source
Thrown at src/openai/resources/containers/containers.py:145
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> ContainerRetrieveResponse:
"""
Retrieve Container
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 container_id:
raise ValueError(f"Expected a non-empty value for `container_id` but received {container_id!r}")
return self._get(
path_template("/containers/{container_id}", container_id=container_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=ContainerRetrieveResponse,
)
def list(
self,
*,
after: str | Omit = omit,
limit: int | Omit = omit,
name: str | Omit = omit,View on GitHub (pinned to 9917c6e28e)
Solutions
- Capture the id from `container = client.containers.create(...)` and pass `container.id`.
- Validate env/DB-sourced ids are non-empty strings before use.
- Check the keyword argument spelling.
Example fix
# before
client.containers.retrieve(container_id=os.getenv("CONTAINER_ID"))
# after
cid = os.getenv("CONTAINER_ID")
if not cid:
raise RuntimeError("CONTAINER_ID not set")
client.containers.retrieve(container_id=cid) Defensive patterns
Strategy: validation
Validate before calling
if not container_id:
raise ValueError("container_id must be non-empty")
client.containers.retrieve(container_id) Type guard
def is_valid_id(value: object) -> bool:
return isinstance(value, str) and bool(value.strip()) Prevention
- Capture container.id from the create response.
- Fail fast on missing env-sourced ids at startup.
When it happens
Trigger: `client.containers.retrieve("")` or passing a None container id from a create response that wasn't captured or a config lookup miss.
Common situations: Using the Codex/containers API with ids stored in env or DB where the field is absent; passing the container object instead of `.id`.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Expected a non-empty value for `project_id` but received {pr
- Expected a non-empty value for `project_id` but received {pr
- Expected a non-empty value for `project_id` but received {pr
- Expected a non-empty value for `group_id` but received {grou
- Expected a non-empty value for `project_id` but received {pr
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/7aee4fe327794b37.
Report an issue: GitHub.