37ffd4c9e0
psycopg2 treats Python lists as PostgreSQL arrays (bigint[]) rather than JSON, causing a DatatypeMismatch error on the json/jsonb column. Serializing with json.dumps() before the raw SQL INSERT fixes the type error. Also wrap per-day INSERT in try/except+rollback so one bad day doesn't abort the entire session, and add db.rollback() in tasks.py after sync_wellness failure so the final status-update commit can always succeed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>