Description of the Bug
In backend/app/routes/profile.py, the avatar upload path is hardcoded as a relative path:
UPLOAD_DIR = Path("uploads/avatars")
UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
This runs at import time (not application startup). The relative path depends on the current working directory at the moment the module is imported. In production (Docker with gunicorn or uvicorn workers), the CWD may not be what's expected.
Contrast this with how the document upload path is handled:
backend/app/config.py: UPLOAD_DIR: str = "./data/uploads" — a configurable setting
backend/app/main.py (line ~61): os.makedirs(settings.UPLOAD_DIR, exist_ok=True) — runs properly in the lifespan startup event
The avatar upload path should follow the same pattern: configurable via settings, and created during application startup, not at import time.
Steps to Reproduce
- Start the application in Docker using
docker compose --profile cpu up --build
- Upload an avatar
- The file may be written to an unexpected directory (relative to the worker's CWD)
- Subsequent requests to serve the avatar may fail with 404 because the path doesn't match
Expected Behavior
Avatar upload directory should be configurable through settings and should be created during application startup (lifespan event), not at module import time.
Affected File
backend/app/routes/profile.py (lines ~16-17)
Suggested Fix
Add AVATAR_UPLOAD_DIR to the Settings model in config.py and use it instead of the hardcoded relative path. Move the directory creation to the application lifespan startup.
GSSoC '26
Description of the Bug
In
backend/app/routes/profile.py, the avatar upload path is hardcoded as a relative path:This runs at import time (not application startup). The relative path depends on the current working directory at the moment the module is imported. In production (Docker with gunicorn or uvicorn workers), the CWD may not be what's expected.
Contrast this with how the document upload path is handled:
backend/app/config.py:UPLOAD_DIR: str = "./data/uploads"— a configurable settingbackend/app/main.py(line ~61):os.makedirs(settings.UPLOAD_DIR, exist_ok=True)— runs properly in the lifespan startup eventThe avatar upload path should follow the same pattern: configurable via settings, and created during application startup, not at import time.
Steps to Reproduce
docker compose --profile cpu up --buildExpected Behavior
Avatar upload directory should be configurable through settings and should be created during application startup (lifespan event), not at module import time.
Affected File
backend/app/routes/profile.py(lines ~16-17)Suggested Fix
Add
AVATAR_UPLOAD_DIRto the Settings model inconfig.pyand use it instead of the hardcoded relative path. Move the directory creation to the application lifespan startup.GSSoC '26