[BUGFIX] : Leaking Soft-Deleted Documents in Global Chat RAG Retrieval #517
Open
hrshjswniii wants to merge 3 commits into
Open
[BUGFIX] : Leaking Soft-Deleted Documents in Global Chat RAG Retrieval #517hrshjswniii wants to merge 3 commits into
hrshjswniii wants to merge 3 commits into
Conversation
d058744 to
0ac2bcb
Compare
Owner
|
Merge COnflicts @hrshjswniii Solve them and ping me |
Contributor
Author
|
Hii @param20h , merge conflicts has been resolved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🔗 Related Issue
Closes #486
📝 What does this PR do?
This PR resolves the data-isolation / security bug where soft-deleted documents (where
is_deleted = Truein SQLite) were leaking into global/unscoped chatbot retrieval:retrievefunction in retriever.py to check the database for active document IDs. If no specificdocument_idis supplied, it queries for a whitelist of all non-deleted (is_deleted=False) document IDs belonging to the querying user.CustomVectorRetrieverasdocument_ids, which filters vector store queries viawhere_filter = {"document_id": {"$in": document_ids}}.CustomBM25Retrieverasdocument_idsand updatedquery_bm25in bm25.py to skip index.pklfiles that do not match the active list.test_retrieve_excludes_soft_deleted_documentsto test_retriever.py to assert that retrieval ignores soft-deleted documents under general/global chat scopes.🗂️ Type of Change
🧪 How was this tested?
test_retrieve_excludes_soft_deleted_documentsinbackend/tests/test_retriever.py).venv/Scripts/pytest— all 120 tests passed)✅ Self-Review Checklist
dev, notmainmainbranch or any HuggingFace deployment config