From 50d61b57741976fbaec17097591b8756a5e2c5c4 Mon Sep 17 00:00:00 2001 From: Mattias Thall Date: Tue, 26 May 2026 22:04:35 +0200 Subject: [PATCH] Fix crawled_at type error in get_channel SQLite returns datetime columns as strings via raw text() queries. Parse crawled_at safely before comparing against utcnow(). Co-Authored-By: Claude Sonnet 4.6 --- backend/routers/channels.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/routers/channels.py b/backend/routers/channels.py index 6b06ac0..c522388 100644 --- a/backend/routers/channels.py +++ b/backend/routers/channels.py @@ -579,11 +579,17 @@ def get_channel( raise HTTPException(status_code=404, detail="Channel not found") # Re-index in the background if stale (not crawled in the last hour) - crawled_at = row.get("crawled_at") - stale = ( - crawled_at is None - or (datetime.utcnow() - crawled_at).total_seconds() > 3600 - ) + stale = True + try: + crawled_at_raw = row.get("crawled_at") + if crawled_at_raw: + crawled_at = ( + crawled_at_raw if isinstance(crawled_at_raw, datetime) + else datetime.fromisoformat(str(crawled_at_raw)) + ) + stale = (datetime.utcnow() - crawled_at).total_seconds() > 3600 + except Exception: + pass if stale: background_tasks.add_task(_index_channel_task, channel_id, current_user.id)