-
Notifications
You must be signed in to change notification settings - Fork 23
5 bugs found during code review: crash, ignored env var, missing state field, hardcoded model, typo #259
Description
Found these during a thorough code review. All are small, isolated bugs.
Bug 1: process_pdf_docs crashes on corrupted PDF (UnboundLocalError)
File: backend/src/tools/process_pdf.py:30-35
When PdfStreamError is caught, the except block logs the error but doesn't return. Execution falls through to line 35 which iterates over documents — but documents was never assigned.
try:
documents = loader.load_and_split(text_splitter=text_splitter)
except PdfStreamError:
logging.error(f"Error processing PDF: {file_path} is corrupted or incomplete.")
# ← no return here!
for doc in documents: # ← UnboundLocalErrorFix: Add return [] in the except block.
Bug 2: FAISS_DB_PATH env var is defined but never read
File: backend/src/vectorstores/faiss.py:199-203
.env.example defines FAISS_DB_PATH=./.faissdb/faiss_index, but get_db_path() always computes a hardcoded relative path (../../../faiss_db), completely ignoring the env var.
Fix: Check os.getenv("FAISS_DB_PATH") first, fall back to the computed path.
Bug 3: context_list missing from AgentState TypedDict
File: backend/src/agents/retriever_typing.py
The ToolNode.get_node() method in retriever_rag.py:61 returns {"context_list": doc_texts}, but AgentState has no context_list field. The data is silently dropped by LangGraph.
Fix: Add context_list: Annotated[list[str], add_messages] to AgentState.
Bug 4: Hardcoded gemini-2.0-flash in helpers endpoint
File: backend/src/api/routers/helpers.py:14
The suggested questions endpoint hardcodes model = "gemini-2.0-flash", ignoring the GOOGLE_GEMINI env var that the main conversations endpoint respects.
Fix: Map GOOGLE_GEMINI env var to model string, consistent with conversations.py.
Bug 5: Typo in main RAG prompt
File: backend/src/prompts/prompt_templates.py:15
"Sorry its not avaiable in my knowledge base." — two issues: missing comma/apostrophe and "avaiable" should be "available".
Fix: "Sorry, it's not available in my knowledge base."