-
-
Notifications
You must be signed in to change notification settings - Fork 1
tech-debt(knowledge): naive datetime.now() calls throughout codebase — should use timezone.utc #3613
Copy link
Copy link
Closed
Description
Problem
While fixing PR #3609 (knowledge/memory_graph/query_processor.py), naive datetime.now() calls were found and replaced with datetime.now(tz=timezone.utc). However, this pattern likely exists broadly across the codebase and will produce incorrect time-range filters on servers not running in UTC.
Impact
- Time-range FT.SEARCH filters (
@created_at:[{ts} +inf]) compute incorrect epoch timestamps when the server timezone is not UTC - Audit logs, TTL calculations, and stream keys using
strftimemay be off by hours relative to actual UTC time
Fix
Audit all datetime.now() calls and replace with datetime.now(tz=timezone.utc) (or datetime.utcnow() where only naive timestamps are needed, with a comment explaining why).
Suggested grep: grep -r "datetime\.now()" autobot-backend/ --include="*.py" -l
Acceptance Criteria
- No bare
datetime.now()calls remain in production code paths that involve timestamps stored in Redis or databases -
from datetime import timezoneimported where needed
Reactions are currently unavailable