yaml importer uses incorrect timestamps when the server isn't in UTC
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1k
- Forks
- 412
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 3
Description
the yaml importer creates aware datetime objects with the timezone set to utc. sqlalchemy doesn't seem to enjoy these:
>>> import cms.db
>>> from datetime import datetime, timezone
>>> session = cms.db.Session()
>>> contest = cms.db.Contest.get_from_id(1, session)
>>> contest.start = datetime(2025, 9, 28, tzinfo=timezone.utc)
>>> contest.start
datetime.datetime(2025, 9, 28, 0, 0, tzinfo=datetime.timezone.utc)
>>> session.commit()
>>> contest.start
datetime.datetime(2025, 9, 28, 3, 0)
short term fix: we need to convert these aware datetimes to naive before passing them to sqlalchemy. longer term fix: we should probably be using aware datetimes instead... and possibly upgrading our sqlalchemy (it already throws warnings about deprecated datetime methods)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read cmscontrib/loaders/italy_yaml.py at lines 127-131 and reproduce the importer with the server in a non-UTC timezone. Check how the resulting datetime is persisted through SQLAlchemy, then verify that imported timestamps retain the intended value without timezone-related conversion or warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100