Fix: Resolve OOM DoS Vulnerability and Optimize FAISS I/O Caching (Clean)#294
Open
Adar5 wants to merge 4 commits intojenkinsci:mainfrom
Open
Fix: Resolve OOM DoS Vulnerability and Optimize FAISS I/O Caching (Clean)#294Adar5 wants to merge 4 commits intojenkinsci:mainfrom
Adar5 wants to merge 4 commits intojenkinsci:mainfrom
Conversation
fc4181d to
360bc21
Compare
360bc21 to
ae2cec8
Compare
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.
Per Leo's suggestion, I am opening this clean branch to isolate only the necessary fixes for the OOM vulnerability and FAISS caching, leaving behind any unrelated noisy commits from the previous PR.
Key Changes:
OOM DoS Mitigation (Defense-in-Depth):
Implemented a strict 2000-character truncation shield on all input gateways (Standard Chat, WebSockets, and File Upload endpoints) to prevent massive string payloads from exhausting RAM.
Migrated from ConversationBufferMemory to ConversationBufferWindowMemory(k=10) to bound the session history, preventing long conversations from causing gradual memory leaks while preserving the secure persistence feature.
FAISS I/O Caching:
Applied @lru_cache(maxsize=1) strictly to the FAISS index and metadata loaders to prevent redundant disk reads.
Refactored dynamic loggers out of the RAG cache boundary to resolve unhashable type errors during inference.
Test Suite Modernization:
Consolidated pytest_plugins from nested conftest.py files into a single root-level conftest.py to fix collection errors in newer Pytest versions (8.4.1+).
Testing:
Successfully survived local stress testing using extreme multi-megabyte payload scripts without causing Uvicorn crashes or memory exhaustion.
Full test suite passing locally (161/161 passed).