From 0278a8e4a6ac4608485a0d8f278ccd297ed16b5a Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 22 Mar 2026 14:33:01 +0100 Subject: [PATCH] fix: photo upload date parameter parsing Problem: Photos were always getting NULL date instead of form date, causing frontend to fallback to created timestamp (today). Root cause: FastAPI requires Form() wrapper for form fields when mixing with File() parameters. Without it, the date parameter was treated as query parameter and always received empty string. Solution: - Import Form from fastapi - Change date parameter from str="" to str=Form("") - Return photo_date instead of date in response (consistency) Now photos correctly use the date from the upload form and can be backdated when uploading later. Co-Authored-By: Claude Opus 4.6 --- backend/routers/photos.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/routers/photos.py b/backend/routers/photos.py index 24a42f7..daa5ca9 100644 --- a/backend/routers/photos.py +++ b/backend/routers/photos.py @@ -9,7 +9,7 @@ import logging from pathlib import Path from typing import Optional -from fastapi import APIRouter, UploadFile, File, Header, HTTPException, Depends +from fastapi import APIRouter, UploadFile, File, Form, Header, HTTPException, Depends from fastapi.responses import FileResponse import aiofiles @@ -26,7 +26,7 @@ PHOTOS_DIR.mkdir(parents=True, exist_ok=True) @router.post("") -async def upload_photo(file: UploadFile=File(...), date: str="", +async def upload_photo(file: UploadFile=File(...), date: str=Form(""), x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)): """Upload progress photo.""" pid = get_pid(x_profile_id) @@ -62,7 +62,7 @@ async def upload_photo(file: UploadFile=File(...), date: str="", # Phase 2: Increment usage counter increment_feature_usage(pid, 'photos') - return {"id":fid,"date":date} + return {"id":fid,"date":photo_date} @router.get("/{fid}")