Skip to content

[Bug]: AttributeError: 'NoneType' object has no attribute 'merge_from' on Concurrent Uploads to the Same Session #574

Description

@Srejoye

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

  1. Create a session by starting (but not completing) a first upload.
  2. Immediately issue a second upload to the same session_id before the vectorstore is swapped in.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestfeatureA new feature or improvementlevel:criticalrag-serviceFastAPI / model service work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions