openai/openai-python · error · ValueError

Expected a non-empty value for `vector_store_id` but receive

Error message

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

What it means

The synchronous `retrieve` on vector stores validates that `vector_store_id` is a non-empty string before GETting `/vector_stores/{vector_store_id}`. An empty or None id raises this ValueError immediately, before any HTTP traffic.

Source

Thrown at src/openai/resources/vector_stores/vector_stores.py:175

        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx2.Timeout | None | NotGiven = not_given,
    ) -> VectorStore:
        """
        Retrieves a vector store.

        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 vector_store_id:
            raise ValueError(f"Expected a non-empty value for `vector_store_id` but received {vector_store_id!r}")
        extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
        return self._get(
            path_template("/vector_stores/{vector_store_id}", vector_store_id=vector_store_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=VectorStore,
        )

    def update(
        self,
        vector_store_id: str,
        *,
        expires_after: Optional[vector_store_update_params.ExpiresAfter] | Omit = omit,

View on GitHub (pinned to 9917c6e28e)

Solutions

  1. Confirm you are passing a literal store id string (starts with 'vs-').
  2. Print the variable's value and origin right before the call.
  3. If it comes from an assistant, read it from the correct nested field of tool_resources.file_search.

Example fix

# before
vs = client.vector_stores.retrieve(vector_store_id=store_id)  # store_id is None

# after
store_id = assistant.tool_resources.file_search.vector_store_ids[0] if assistant.tool_resources else None
if not store_id:
    raise ValueError("no vector store attached to assistant")
vs = client.vector_stores.retrieve(vector_store_id=store_id)
Defensive patterns

Strategy: validation

Validate before calling

if not vector_store_id:
    raise ValueError("vector_store_id required to retrieve a store")

Type guard

def is_store_id(value: object) -> bool:
    return isinstance(value, str) and value.startswith("vs-")

Prevention

When it happens

Trigger: Calling client.vector_stores.retrieve(vector_store_id="" or None); usually a stale id variable, an unset env/config value, or a wrong attribute on an Assistant/Thread object.

Common situations: Using assistant.tool_resources instead of the actual store id, ids from deleted stores still referenced in app state, or config keys differing between environments.

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


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