{"record":{"id":"4754e8528bd7e538","repo":"openai/openai-python","slug":"expected-a-non-empty-value-for-vector-store-id-b-4754e8","errorCode":null,"errorMessage":"Expected a non-empty value for `vector_store_id` but received {vector_store_id!r}","messagePattern":"Expected a non-empty value for `vector_store_id` but received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/vector_stores/files.py","lineNumber":96,"sourceCode":"          attributes: Set of 16 key-value pairs that can be attached to an object. This can be useful\n              for storing additional information about the object in a structured format, and\n              querying for objects via API or the dashboard. Keys are strings with a maximum\n              length of 64 characters. Values are strings with a maximum length of 512\n              characters, booleans, or numbers.\n\n          chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`\n              strategy. Only applicable if `file_ids` is non-empty.\n\n          extra_headers: Send extra headers\n\n          extra_query: Add additional query parameters to the request\n\n          extra_body: Add additional JSON properties to the request\n\n          timeout: Override the client-level default timeout for this request, in seconds\n        \"\"\"\n        if not vector_store_id:\n            raise ValueError(f\"Expected a non-empty value for `vector_store_id` but received {vector_store_id!r}\")\n        extra_headers = {\"OpenAI-Beta\": \"assistants=v2\", **(extra_headers or {})}\n        return self._post(\n            path_template(\"/vector_stores/{vector_store_id}/files\", vector_store_id=vector_store_id),\n            body=maybe_transform(\n                {\n                    \"file_id\": file_id,\n                    \"attributes\": attributes,\n                    \"chunking_strategy\": chunking_strategy,\n                },\n                file_create_params.FileCreateParams,\n            ),\n            options=make_request_options(\n                extra_headers=extra_headers,\n                extra_query=extra_query,\n                extra_body=extra_body,\n                timeout=timeout,\n                security={\"bearer_auth\": True},\n            ),","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/vector_stores/files.py#L78-L114","documentation":"Creating a vector store file via `client.vector_stores.files.create` requires a non-empty `vector_store_id`. The SDK validates path parameters before the POST to `/vector_stores/{vector_store_id}/files` and raises ValueError for empty values to avoid malformed requests.","triggerScenarios":"Calling `client.vector_stores.files.create(vector_store_id=\"\" or None, file_id=\"file-abc\")`, or when the vector store was created but its `.id` was not captured; `upload` and `upload_and_poll` forward their `vector_store_id` argument and hit the same check.","commonSituations":"Passing a `VectorStore` object instead of its `.id`, an unset environment/config variable holding the store id, or a store created in a different flow/variable scope.","solutions":["Use the id from creation: `vs = client.vector_stores.create(...)` then `vs.id`","If passing an object, extract `.id`: `vector_store_id=store.id`","Print/log the variable right before the call to confirm it is populated"],"exampleFix":"# before\nclient.vector_stores.files.create(vector_store_id=\"\", file_id=\"file-abc\")\n\n# after\nvs = client.vector_stores.create(name=\"docs\")\nfile = client.vector_stores.files.create(vector_store_id=vs.id, file_id=\"file-abc\")","handlingStrategy":"validation","validationCode":"vs_id = getattr(store, \"id\", store)  # accept object or id\nif not isinstance(vs_id, str) or not vs_id:\n    raise ValueError(f\"vector_store_id must be a non-empty string, got {vs_id!r}\")\nfile = client.vector_stores.files.create(vector_store_id=vs_id, file_id=file_id)","typeGuard":"from openai.types.vector_store import VectorStore\n\ndef resolve_store_id(v: str | VectorStore) -> str:\n    return v.id if isinstance(v, VectorStore) else v","tryCatchPattern":"try:\n    file = client.vector_stores.files.create(vector_store_id=vs_id, file_id=file_id)\nexcept ValueError as e:\n    logger.error(\"Bad arguments: %s\", e)\n    raise","preventionTips":["Capture vs.id from client.vector_stores.create immediately","Use keyword arguments to avoid positional mix-ups","Centralize id resolution (object or string) in one helper"],"tags":["vector-stores","files","validation","valueerror","python"],"backgroundTag":"empty-required-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}