Fix: Correct parameter passing in vector_stores poll() methods #2734
+181
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2724 -
vector_stores.file_batches.poll()now correctly returnsVectorStoreFileBatchinstead ofVectorStoreProblem
When users called
client.vector_stores.file_batches.poll(), the method returned aVectorStoreobject with the vector store's ID instead of returning theVectorStoreFileBatchobject with the batch ID.User's Reproduction
Root Cause
The
poll()method internally callsself.with_raw_response.retrieve()to fetch the batch status. When passing the first parameter (batch_idorfile_id) as a positional argument, the method wrapper didn't properly preserve the parameter mapping, causing parameters to be swapped.Code at fault (file_batches.py:305):
This resulted in the API being called with the wrong URL:
GET /vector_stores/{vs_id}/file_batches/{batch_id}GET /vector_stores/{batch_id}or similar malformed URLSolution
Changed all
poll()methods to pass the first parameter as a keyword argument instead of positional:This ensures explicit parameter mapping and prevents confusion in the method wrapper, while maintaining backward compatibility (Python allows positional parameters to be passed as keywords).
Changes
Fixed 4 instances of this bug across 2 files:
src/openai/resources/vector_stores/file_batches.py:
retrieve(batch_id, ...)→retrieve(batch_id=batch_id, ...)(sync)retrieve(batch_id, ...)→retrieve(batch_id=batch_id, ...)(async)src/openai/resources/vector_stores/files.py:
retrieve(file_id, ...)→retrieve(file_id=file_id, ...)(sync)retrieve(file_id, ...)→retrieve(file_id=file_id, ...)(async)Testing
Before Fix
{ "id": "vs_6905db4d...", // ❌ Vector Store ID "object": "vector_store", // ❌ Wrong type "name": "test_vector_store", // ❌ VS field "file_counts": {...} // Mixed fields }After Fix
{ "id": "vsfb_ibj_6905db4e...", // ✅ Batch ID "object": "vector_store.file_batch", // ✅ Correct type "status": "completed", // ✅ Batch fields "file_counts": {...} // ✅ Batch fields }Impact
file_batches.poll()andfiles.poll()now return correct object typesvector_stores.file_batches.poll()orvector_stores.files.poll()Related
files.poll()which likely had the same bug but wasn't reported yetChecklist