openai/openai-python · error · ValueError
Expected a non-empty value for `certificate_id` but received
Error message
Expected a non-empty value for `certificate_id` but received {certificate_id!r} What it means
The sync Admin Certificates `retrieve` method requires a non-empty `certificate_id`; the GET /organization/certificates/{certificate_id} path cannot be built without it, so the SDK raises ValueError immediately.
Source
Thrown at src/openai/resources/admin/organization/certificates.py:136
"""
Get a certificate that has been uploaded to the organization.
You can get a certificate regardless of whether it is active or not.
Args:
include: A list of additional fields to include in the response. Currently the only
supported value is `content` to fetch the PEM content of the certificate.
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 certificate_id:
raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
return self._get(
path_template("/organization/certificates/{certificate_id}", certificate_id=certificate_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"include": include}, certificate_retrieve_params.CertificateRetrieveParams),
security={"admin_api_key_auth": True},
),
cast_to=Certificate,
)
def update(
self,
certificate_id: str,
*,
name: str | Omit = omit,View on GitHub (pinned to 9917c6e28e)
Solutions
- Capture the id from the create() response and persist it
- Validate non-empty before calling retrieve
Example fix
# before
client.admin.certificates.retrieve(parsed_id)
# after
if not parsed_id:
raise ValueError('failed to parse certificate id')
client.admin.certificates.retrieve(parsed_id) Defensive patterns
Strategy: validation
Validate before calling
if not certificate_id:
raise ValueError('certificate_id is required')
client.admin.certificates.retrieve(certificate_id) Type guard
def is_nonempty_id(v: object) -> bool:
return isinstance(v, str) and bool(v.strip()) Prevention
- Persist ids returned from create()
- Test id-parsing logic against unexpected formats
When it happens
Trigger: client.admin.certificates.retrieve('') or retrieve(None), e.g. parsing an id from a filename or URL that didn't match.
Common situations: Extracting certificate ids with a regex/split that yields '' on unexpected input, or storing certificates without persisting the returned id.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
Related errors
- Expected a non-empty value for `key_id` but received {key_id
- Expected a non-empty value for `project_id` but received {pr
- Expected a non-empty value for `user_id` but received {user_
- Expected a non-empty value for `project_id` but received {pr
- 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/3d05f1a3291be6ab.
Report an issue: GitHub.