Skip to content

Commit a107d2f

Browse files
pmcfadinclaude
andcommitted
fix: pass uuid1() instead of video_id as activity_id for view events
video_id is a v4 UUID but user_activity.activity_id is a TimeUUID (v1) column in Cassandra. Passing a v4 UUID caused INVALID_DATABASE_QUERY errors on every video view. Fix by dropping the explicit activity_id argument so record_user_activity auto-generates a uuid1() as intended. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8b46986 commit a107d2f

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.env
22
.python-version
3-
.DS_Store
3+
.DS_Store
44

55
# Python
66
__pycache__/
@@ -15,6 +15,11 @@ __pycache__/
1515

1616
*.log
1717

18+
# Data files (source of truth is in killrvideo-data project)
19+
data/
20+
logs/
21+
dsbulk.conf
22+
1823
certs/
1924

2025
.vscode/

app/services/video_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ async def record_video_view(
477477
await record_user_activity(
478478
userid=effective_user_id,
479479
activity_type="view",
480-
activity_id=video_id,
481480
)
482481
except Exception:
483482
logger.warning("user_activity insert failed for view; ignoring", exc_info=True)

tests/services/test_video_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ async def test_record_video_view_authenticated_user_activity():
286286
vid, viewer_user_id=viewer_id, db_table=mock_stats_table
287287
)
288288

289-
# record_user_activity should be called with the real user ID and video_id
289+
# record_user_activity should be called with the real user ID; no activity_id
290+
# because view events auto-generate a uuid1() to satisfy the TimeUUID column
290291
mock_record_user_activity.assert_awaited_once_with(
291292
userid=viewer_id,
292293
activity_type="view",
293-
activity_id=vid,
294294
)
295295

296296

@@ -318,11 +318,11 @@ async def test_record_video_view_anonymous_user_activity():
318318
vid, viewer_user_id=None, db_table=mock_stats_table
319319
)
320320

321-
# record_user_activity should be called with the anonymous sentinel UUID and video_id
321+
# record_user_activity should be called with the anonymous sentinel UUID; no activity_id
322+
# because view events auto-generate a uuid1() to satisfy the TimeUUID column
322323
mock_record_user_activity.assert_awaited_once_with(
323324
userid=ANONYMOUS_USER_ID,
324325
activity_type="view",
325-
activity_id=vid,
326326
)
327327

328328

0 commit comments

Comments
 (0)