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: # ← UnboundLocalError
Fix: 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."
Found these during a thorough code review. All are small, isolated bugs.
Bug 1:
process_pdf_docscrashes on corrupted PDF (UnboundLocalError)File:
backend/src/tools/process_pdf.py:30-35When
PdfStreamErroris caught, theexceptblock logs the error but doesn't return. Execution falls through to line 35 which iterates overdocuments— butdocumentswas never assigned.Fix: Add
return []in the except block.Bug 2:
FAISS_DB_PATHenv var is defined but never readFile:
backend/src/vectorstores/faiss.py:199-203.env.exampledefinesFAISS_DB_PATH=./.faissdb/faiss_index, butget_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_listmissing fromAgentStateTypedDictFile:
backend/src/agents/retriever_typing.pyThe
ToolNode.get_node()method inretriever_rag.py:61returns{"context_list": doc_texts}, butAgentStatehas nocontext_listfield. The data is silently dropped by LangGraph.Fix: Add
context_list: Annotated[list[str], add_messages]toAgentState.Bug 4: Hardcoded
gemini-2.0-flashin helpers endpointFile:
backend/src/api/routers/helpers.py:14The suggested questions endpoint hardcodes
model = "gemini-2.0-flash", ignoring theGOOGLE_GEMINIenv var that the main conversations endpoint respects.Fix: Map
GOOGLE_GEMINIenv var to model string, consistent withconversations.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."