openai/openai-python · error · ValueError

Expected a non-empty value for `skill_id` but received {skil

Error message

Expected a non-empty value for `skill_id` but received {skill_id!r}

What it means

Sync Skills.retrieve validates that skill_id is non-empty before building GET /skills/{skill_id}. This is a client-side ArgumentError-style guard common to all generated path-parameter methods, ensuring the templated URL would not degrade to /skills/ or /skills/None.

Source

Thrown at src/openai/resources/skills/skills.py:150

        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx2.Timeout | None | NotGiven = not_given,
    ) -> Skill:
        """
        Get a skill by its 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 skill_id:
            raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}")
        return self._get(
            path_template("/skills/{skill_id}", skill_id=skill_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=Skill,
        )

    def update(
        self,
        skill_id: str,
        *,
        default_version: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

View on GitHub (pinned to 9917c6e28e)

Solutions

  1. Pass a real skill ID returned from client.skills.create() or list()
  2. Validate the variable before the call: if not skill_id: ...
  3. When deriving from a response, confirm the field name (id) and that the object was created successfully

Example fix

# before
skill = client.skills.retrieve(skill_id="")

# after
skill = client.skills.retrieve(skill_id="skill-abc123")
Defensive patterns

Strategy: validation

Validate before calling

assert isinstance(skill_id, str) and skill_id, f"skill_id must be set, got {skill_id!r}"
skill = client.skills.retrieve(skill_id=skill_id)

Type guard

def is_valid_skill_id(value: object) -> bool:
    return isinstance(value, str) and bool(value.strip())

Prevention

When it happens

Trigger: Calling client.skills.retrieve(skill_id=""), retrieve(None), or retrieve(skill_id=some_empty_var). The check is `if not skill_id`, so empty string, None, and other falsy values all trigger it.

Common situations: Copy-pasting sample code and forgetting to substitute the ID; deriving IDs from dict.get("id") on an object that uses a different key; blank entries in bulk-processing scripts.

Related errors


AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28). Data as JSON: /api/errors/c63b8e3857817e56. Report an issue: GitHub.