Description
The User.from_dict method parses dates with a fragile string comparison that only matches one specific format and has no timezone handling:
# src/quads/server/models.py:455-459
for attr in ['last_login', 'first_login']:
if data.get(attr):
if isinstance(data[attr], str):
if data[attr] != '1970-01-01T00:00:00':
setattr(self, attr, datetime.fromisoformat(data[attr]))
else:
setattr(self, attr, None)
Impact
- Hardcoded epoch comparison is fragile and format-specific
- No timezone handling on parsed datetimes
- Any deviation in date format causes unexpected behavior
Recommended Fix
Use a proper date parsing library with timezone handling (e.g., dateutil.parser.parse) and handle the epoch/null case more robustly.
Description
The
User.from_dictmethod parses dates with a fragile string comparison that only matches one specific format and has no timezone handling:Impact
Recommended Fix
Use a proper date parsing library with timezone handling (e.g.,
dateutil.parser.parse) and handle the epoch/null case more robustly.