Skip to content

fix: preserve file batch id when polling completes#3238

Open
nightcityblade wants to merge 2 commits into
openai:mainfrom
nightcityblade:fix/issue-2724
Open

fix: preserve file batch id when polling completes#3238
nightcityblade wants to merge 2 commits into
openai:mainfrom
nightcityblade:fix/issue-2724

Conversation

@nightcityblade
Copy link
Copy Markdown

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Fixes #2724.

vector_stores.file_batches.poll() can receive a completed vector store payload from the poll endpoint. In that case, coerce the final payload back to a VectorStoreFileBatch with the requested batch id/vector store id so the helper returns the batch the caller polled for.

Additional context & links

Added sync and async regression coverage for a completed vector store-shaped poll response.

Tests run:

PYTHONPATH=src pytest tests/api_resources/vector_stores/test_file_batches.py::test_poll_coerces_completed_vector_store_response tests/api_resources/vector_stores/test_file_batches.py::test_async_poll_coerces_completed_vector_store_response -q -o addopts=""
PYTHONPATH=src python3 -m mypy src/openai/resources/vector_stores/file_batches.py --ignore-missing-imports
PYTHONPATH=src python3 -m ruff check src/openai/resources/vector_stores/file_batches.py tests/api_resources/vector_stores/test_file_batches.py

@nightcityblade nightcityblade requested a review from a team as a code owner May 14, 2026 15:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7135072c9b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +41 to +49
return construct_type_unchecked(
value={
**data,
"id": batch_id,
"object": "vector_store.files_batch",
"vector_store_id": vector_store_id,
},
type_=VectorStoreFileBatch,
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep strict validation for coerced poll responses

When poll() receives a vector_store payload, this path builds VectorStoreFileBatch via construct_type_unchecked, which bypasses _strict_response_validation entirely. That means clients that explicitly enabled strict validation can silently accept malformed fields (wrong enum/value types) in this branch instead of getting a validation error, unlike the normal response.parse() path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch — I switched the coerced vector_store poll path to run back through the client response processor so strict validation still applies, and added sync/async regression coverage for the malformed payload case. Updated in 0e79e20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The return value of the vector_stores.file_batches.poll method contains the ID of the VectorStore.

1 participant