Skip to content

[BUG][LOW] Fragile date parsing in User.from_dict with no timezone handling #681

Description

@kambiz-aghaiepour

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions