Summary
Summary
The endpoint handler for the /ask route in main.py is declared twice consecutively under the function name ask_question.
The first declaration (lines 3388-3389) is decorated with @app.post("/ask") but only performs session cleanup and returns nothing. The second declaration (starting at line 3392) contains the actual Q&A/inference implementation but has no route decorator.
In Python, redeclaring a function in the same scope overrides the previous name in the namespace. However, FastAPI registers the first decorated function during application startup. When a client calls /ask, FastAPI routes the request to the first (empty) implementation, which returns None/null to the client. The actual Q&A logic is unreachable and behaves as dead code.
Steps to reproduce
Steps to Reproduce
- Start the backend RAG service and the Express gateway.
- Upload a PDF and submit a question using the chat input.
- Observe that the API returns
200 OK but a body of null (or empty JSON).
- Inspect the RAG service logs: the Q&A pipeline and model inference never execute.
Expected behavior
Expected Behavior
The /ask endpoint should parse the question, verify the session secret, invoke the LLM model, and return a JSON response containing answer, sources, and mode.
Actual behavior
Actual Behavior
The endpoint returns null with a 200 OK status code, completely bypassing the question-answering logic.
Additional context
Additional Context
The duplicate function declaration in main.py:
@app.post("/ask")
def ask_question(data: Question, _ready: None = Depends(require_models_ready)):
cleanup_expired_sessions()
def ask_question(data: Question):
question = (data.question or "").strip()
Summary
Summary
The endpoint handler for the
/askroute in main.py is declared twice consecutively under the function nameask_question.The first declaration (lines 3388-3389) is decorated with
@app.post("/ask")but only performs session cleanup and returns nothing. The second declaration (starting at line 3392) contains the actual Q&A/inference implementation but has no route decorator.In Python, redeclaring a function in the same scope overrides the previous name in the namespace. However, FastAPI registers the first decorated function during application startup. When a client calls
/ask, FastAPI routes the request to the first (empty) implementation, which returnsNone/nullto the client. The actual Q&A logic is unreachable and behaves as dead code.Steps to reproduce
Steps to Reproduce
200 OKbut a body ofnull(or empty JSON).Expected behavior
Expected Behavior
The
/askendpoint should parse the question, verify the session secret, invoke the LLM model, and return a JSON response containinganswer,sources, andmode.Actual behavior
Actual Behavior
The endpoint returns
nullwith a200 OKstatus code, completely bypassing the question-answering logic.Additional context
Additional Context
The duplicate function declaration in main.py: