Severity
| Severity |
Category |
Issue Type |
| Medium |
Reliability / Forward Compatibility |
Deprecated stdlib usage |
Summary
praisonaiui/server.py calls datetime.utcnow() in two places to timestamp chat messages and session events. datetime.utcnow() was deprecated in Python 3.12 and will be removed in Python 3.14. On Python 3.13 it already emits a DeprecationWarning. This will turn into a runtime error in the next Python release — silently breaking all chat session timestamps without any code change by the user.
Affected Components
| Component |
Location |
Call |
server.py |
Line 773 |
"created_at": datetime.utcnow().isoformat() |
server.py |
Line 851 |
"timestamp": datetime.utcnow().isoformat() |
File: praisonaiui/server.py
Package: aiui 0.3.111 (installed as praisonaiui)
Expected vs Actual Behavior
|
Behavior |
| Expected |
Timestamps use datetime.now(timezone.utc) — the stdlib-recommended, timezone-aware replacement |
| Actual |
datetime.utcnow() is called — naive UTC datetime, deprecated, emits DeprecationWarning on Python 3.12+, removed in Python 3.14 |
Reproduction Steps
# Verify the call is present in the installed package
import inspect, importlib, praisonaiui.server as srv
src = inspect.getsource(srv)
for i, line in enumerate(src.splitlines(), 1):
if "utcnow" in line:
print(f"Line {i}: {line.strip()}")
Output:
Line 773: "created_at": datetime.utcnow().isoformat(),
Line 851: "timestamp": datetime.utcnow().isoformat(),
Or verify with Python warnings enabled:
python -W all -c "from datetime import datetime; datetime.utcnow()"
DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version.
Use timezone-aware objects to represent datetimes in UTC: datetime.now(timezone.utc).
Root Cause Analysis
datetime.utcnow() returns a naive datetime object (no tzinfo). The replacement API datetime.now(timezone.utc) returns a timezone-aware datetime. Python 3.12 formally deprecated utcnow() with a scheduled removal. On Python 3.13 today, this produces warnings in -W error environments (common in CI) and will raise AttributeError once removed in Python 3.14.
Timeline
| Python Version |
Status |
| 3.11 and earlier |
utcnow() works silently |
| 3.12 |
DeprecationWarning added |
| 3.13 (current LTS) |
Warning emitted, -W error CI pipelines fail |
| 3.14 (upcoming) |
utcnow() removed — runtime AttributeError |
Impact Analysis
| Dimension |
Detail |
| Affected environments |
All users on Python 3.13+ with warnings enabled; all users on Python 3.14+ |
| Failure mode |
AttributeError: type object 'datetime' has no attribute 'utcnow' on Python 3.14 |
| Affected features |
Chat session creation (created_at), message timestamps (timestamp) |
| Fix complexity |
Very low — 2-line substitution |
Why This Matters
Python 3.14 has a scheduled release in October 2025. Projects that are already running on Python 3.13 (the current CPython release) are one minor version upgrade away from a broken dashboard. Because both calls sit in request-handling paths, the failure will be immediate and visible to all users — not a rarely triggered edge case.
Suggested Fix
# Before (deprecated)
from datetime import datetime
"created_at": datetime.utcnow().isoformat(), # line 773
"timestamp": datetime.utcnow().isoformat(), # line 851
# After (correct, timezone-aware)
from datetime import datetime, timezone
"created_at": datetime.now(timezone.utc).isoformat(), # line 773
"timestamp": datetime.now(timezone.utc).isoformat(), # line 851
The .isoformat() output format is identical for consumers — this is a drop-in replacement with no API-surface change.
Backward Compatibility
Fully backward compatible. datetime.now(timezone.utc).isoformat() produces the same ISO 8601 string as datetime.utcnow().isoformat(), the only difference being the +00:00 suffix added by the aware version. If downstream consumers need the exact naive format, .replace(tzinfo=None) can be added, but the aware format is strictly more correct and informative.
Suggested Regression Test
import re
from praisonaiui import server
def test_no_utcnow_in_server():
"""server.py must not call the deprecated datetime.utcnow()."""
import inspect
source = inspect.getsource(server)
assert "utcnow" not in source, (
"datetime.utcnow() is deprecated (Python 3.12) and removed in Python 3.14. "
"Use datetime.now(timezone.utc) instead."
)
Acceptance Criteria
Environment
OS : Windows 10 (19045)
Python : 3.13
Package : aiui 0.3.111 (praisonaiui)
Install : pip install "praisonai[claw]"
Severity
Summary
praisonaiui/server.pycallsdatetime.utcnow()in two places to timestamp chat messages and session events.datetime.utcnow()was deprecated in Python 3.12 and will be removed in Python 3.14. On Python 3.13 it already emits aDeprecationWarning. This will turn into a runtime error in the next Python release — silently breaking all chat session timestamps without any code change by the user.Affected Components
server.py"created_at": datetime.utcnow().isoformat()server.py"timestamp": datetime.utcnow().isoformat()File:
praisonaiui/server.pyPackage:
aiui0.3.111 (installed aspraisonaiui)Expected vs Actual Behavior
datetime.now(timezone.utc)— the stdlib-recommended, timezone-aware replacementdatetime.utcnow()is called — naive UTC datetime, deprecated, emitsDeprecationWarningon Python 3.12+, removed in Python 3.14Reproduction Steps
Output:
Or verify with Python warnings enabled:
python -W all -c "from datetime import datetime; datetime.utcnow()"Root Cause Analysis
datetime.utcnow()returns a naivedatetimeobject (notzinfo). The replacement APIdatetime.now(timezone.utc)returns a timezone-awaredatetime. Python 3.12 formally deprecatedutcnow()with a scheduled removal. On Python 3.13 today, this produces warnings in-W errorenvironments (common in CI) and will raiseAttributeErroronce removed in Python 3.14.Timeline
utcnow()works silentlyDeprecationWarningadded-W errorCI pipelines failutcnow()removed — runtimeAttributeErrorImpact Analysis
AttributeError: type object 'datetime' has no attribute 'utcnow'on Python 3.14created_at), message timestamps (timestamp)Why This Matters
Python 3.14 has a scheduled release in October 2025. Projects that are already running on Python 3.13 (the current CPython release) are one minor version upgrade away from a broken dashboard. Because both calls sit in request-handling paths, the failure will be immediate and visible to all users — not a rarely triggered edge case.
Suggested Fix
The
.isoformat()output format is identical for consumers — this is a drop-in replacement with no API-surface change.Backward Compatibility
Fully backward compatible.
datetime.now(timezone.utc).isoformat()produces the same ISO 8601 string asdatetime.utcnow().isoformat(), the only difference being the+00:00suffix added by the aware version. If downstream consumers need the exact naive format,.replace(tzinfo=None)can be added, but the aware format is strictly more correct and informative.Suggested Regression Test
Acceptance Criteria
datetime.utcnow()calls inserver.py(lines 773, 851) replaced withdatetime.now(timezone.utc)from datetime import datetime, timezoneimport updated inserver.pyDeprecationWarningemitted when running the dashboard underpython -W errorutcnowis absent fromserver.pyEnvironment