Skip to content

fix(collections): Use correct file batch ID#1073

Open
vprashrex wants to merge 2 commits into
mainfrom
fix/openai-vector-store-batch-id
Open

fix(collections): Use correct file batch ID#1073
vprashrex wants to merge 2 commits into
mainfrom
fix/openai-vector-store-batch-id

Conversation

@vprashrex

@vprashrex vprashrex commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Issue

Closes #1076

Summary

  • Before: The previous implementation did not use the file batch ID from the create() function when listing failed files.
  • Now: The new implementation utilizes the correct file batch ID for better accuracy in listing failed files.
  • Adjustments were made to the function responsible for listing failed files.
  • Integration of the file batch ID into the previous code structure.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Please add here if any other information is required for the reviewer.

Original PR description

Issue

Closes #PLEASE_TYPE_ISSUE_NUMBER

Summary

Explain the motivation for making this change. What existing problem does the pull request solve?

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

OpenAIVectorStoreCrud.update now separates file-batch creation from polling, retains the creation batch ID for failed-file lookup, updates related tests and mocks, and documents the SDK ID behavior.

Changes

Vector batch ingestion

Layer / File(s) Summary
Separate batch creation and polling
backend/app/crud/rag/open_ai.py
The ingestion flow captures the ID from create(), passes it to poll(), and uses it for failed-file retrieval and logging.
Batch flow and error-path tests
backend/app/tests/crud/rag/test_open_ai.py, backend/app/tests/services/collections/providers/test_openai_provider.py
Tests distinguish creation and polling IDs, verify batch wiring and file arguments, and raise OpenAI exceptions from create().
Shared mocks and ingestion notes
backend/app/tests/utils/llm_provider.py, backend/app/tests/utils/openai.py, docs/wiki/modules/knowledge-base.md
Shared mocks use separate create() and poll() operations, and documentation records the batch-ID behavior and rollback semantics.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: nishika26, prajna1999

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: fixing file batch ID handling in collections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openai-vector-store-batch-id

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title fix(collections): Use file batch ID from create() when listing failed files fix(collections): Use correct file batch ID Jul 23, 2026
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

OpenAPI changes   ⚪ No API surface changes

Note

This PR does not modify the API contract.

main9b76582b · generated by oasdiff

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.45283% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/tests/utils/openai.py 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
backend/app/tests/crud/rag/test_open_ai.py (2)

72-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the self-evident comment.

assert_not_called() already expresses this expectation; retain comments only when they explain rationale. As per coding guidelines, “Write comments and docstrings to explain why something is done, not what the code already shows.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/tests/crud/rag/test_open_ai.py` at line 72, Remove the
self-evident “list_files should not have been called on the happy path” comment
near the assert_not_called() expectation in the test, leaving the assertion
unchanged.

Source: Coding guidelines


44-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add required type annotations to changed test signatures.

Annotate non-self fixture parameters and return values consistently.

  • backend/app/tests/crud/rag/test_open_ai.py#L44-L44: annotate mock_client: MagicMock.
  • backend/app/tests/crud/rag/test_open_ai.py#L75-L75: annotate injected fixtures and add -> None.
  • backend/app/tests/crud/rag/test_open_ai.py#L106-L108: annotate injected fixtures and add -> None.
  • backend/app/tests/crud/rag/test_open_ai.py#L122-L124: annotate injected fixtures and add -> None.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/tests/crud/rag/test_open_ai.py` at line 44, Add the requested
annotations in backend/app/tests/crud/rag/test_open_ai.py: type _wire_batch’s
mock_client parameter as MagicMock, and annotate all non-self injected fixture
parameters plus return values with -> None in the test functions at lines 75,
106-108, and 122-124. Apply the annotations consistently across all four
affected sites.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@backend/app/tests/crud/rag/test_open_ai.py`:
- Line 72: Remove the self-evident “list_files should not have been called on
the happy path” comment near the assert_not_called() expectation in the test,
leaving the assertion unchanged.
- Line 44: Add the requested annotations in
backend/app/tests/crud/rag/test_open_ai.py: type _wire_batch’s mock_client
parameter as MagicMock, and annotate all non-self injected fixture parameters
plus return values with -> None in the test functions at lines 75, 106-108, and
122-124. Apply the annotations consistently across all four affected sites.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 79f5c90e-9ea2-43f6-8dc9-ff715cb54c65

📥 Commits

Reviewing files that changed from the base of the PR and between 49fd4ad and 6ca053f.

📒 Files selected for processing (6)
  • backend/app/crud/rag/open_ai.py
  • backend/app/tests/crud/rag/test_open_ai.py
  • backend/app/tests/services/collections/providers/test_openai_provider.py
  • backend/app/tests/utils/llm_provider.py
  • backend/app/tests/utils/openai.py
  • docs/wiki/modules/knowledge-base.md

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collection: Correct batch ID usage

1 participant