Bug Description
In app/routes/session.py:165, all concurrent batch_predict() requests write to the exact same file temp_batch_predict.csv:
predict_csv_path = base_path / "temp_batch_predict.csv"
If two or more requests arrive simultaneously, they overwrite each other's data, causing incorrect or corrupted gaze predictions for one or both users.
Severity
HIGH — This silently produces wrong results in production whenever concurrent requests occur.
Steps to Reproduce
- Send two
POST /batch_predict requests at the same time with different iris_tracking_data
- Both requests write to
temp_batch_predict.csv concurrently
- One request reads the other's data, producing incorrect predictions
Expected Behavior
Each request should use its own isolated temporary file so concurrent requests never interfere with each other.
Proposed Fix
- Use
uuid4 to generate a unique filename per request: temp_batch_predict_{uuid}.csv
- Clean up the temp file with
os.remove() after prediction completes to prevent disk space leaks (related to CSV cleanup concern)