Summary
Description
In rag-service/main.py, when a client uploads a second PDF to an existing session (requested_session_id is set), the code reads vectorstore = session["vectorstore"] under sessions_lock and then calls vectorstore.merge_from(new_vectorstore) outside that lock (lines 3248–3253). A session's vectorstore is initialised to None at creation time (line 3165) and is only replaced with a real FAISS index at the end of the first upload's critical section.
Affected Files
rag-service/main.py lines 3233–3260 (process_pdf, requested_session_id branch)
Steps to reproduce
- Create a session by starting (but not completing) a first upload.
- Immediately issue a second upload to the same
session_id before the vectorstore is swapped in.
- The second request hits
vectorstore.merge_from(new_vectorstore) where vectorstore is None.
Expected behavior
If a second upload request arrives after the session placeholder is created but before the first upload's vectorstore has been persisted and swapped in, the second request reads None from session["vectorstore"] and then crashes with:
AttributeError: 'NoneType' object has no attribute 'merge_from'
Actual behavior
The exception is caught by the bare except Exception block which raises HTTP 500 back to the client. Meanwhile the first upload may still succeed, leaving the session with a partially-initialised state and an inconsistent document list.
Additional context
No response
Summary
Description
In
rag-service/main.py, when a client uploads a second PDF to an existing session (requested_session_idis set), the code readsvectorstore = session["vectorstore"]undersessions_lockand then callsvectorstore.merge_from(new_vectorstore)outside that lock (lines 3248–3253). A session's vectorstore is initialised toNoneat creation time (line 3165) and is only replaced with a real FAISS index at the end of the first upload's critical section.Affected Files
rag-service/main.pylines 3233–3260 (process_pdf,requested_session_idbranch)Steps to reproduce
session_idbefore the vectorstore is swapped in.vectorstore.merge_from(new_vectorstore)wherevectorstore is None.Expected behavior
If a second upload request arrives after the session placeholder is created but before the first upload's vectorstore has been persisted and swapped in, the second request reads
Nonefromsession["vectorstore"]and then crashes with:Actual behavior
The exception is caught by the bare
except Exceptionblock which raises HTTP 500 back to the client. Meanwhile the first upload may still succeed, leaving the session with a partially-initialised state and an inconsistent document list.Additional context
No response