Repository navigation
fix(clickup): keep the instant an ISO due date names - #15157
Conversation
pytz.localize is only valid on a naive datetime. A trailing Z was stripped and the wall clock localized as the user's own time, moving a UTC due date by the user's offset, and an explicit offset made localize raise, so the surrounding except dropped the due date while the tool still reported success.
|
Flagging the overlap before someone has to work it out: #14093 (for #13922) refactors this same block into a so a Z timestamp is still localized as the user's wall clock (5.5 hours early for Asia/Kolkata) and an offset-aware string still makes pytz.localize raise, which the caller swallows into a task with no due date. If #14093 lands first I will rebase this onto its helper rather than reopening the old shape. If this lands first the helper can take the same parse. |
kodjima33
left a comment
There was a problem hiding this comment.
Confirmed root cause: pytz localize() misused on tz-aware ISO due dates, causing wrong instants or silent due-date drops. Scoped fix + test, CI green. 5/5.
Fixes #15155.
ClickUpClient.create_taskconverts an ISO due date like this:tzis the user'spytzzone (production installspytz==2023.3), andlocalizeis only valid on a naive datetime. Two things go wrong:A UTC due date has its
Zstripped and is then localized as if the wall clock were the user's local time.2026-09-21T17:00:00Zfor an Asia/Kolkata user is stored as 11:30 UTC, five and a half hours before the instant that was asked for.A due date that carries an explicit offset parses as aware, so
localizeraisesValueError: Not naive datetime (tzinfo is already set). The surroundingexcept Exceptionlogs "Could not parse due date" and drops the key, so the task is created with no due date at all, the handler still answers✅ Task created, andnotify_task_createdpushes the user a notification naming the due date they asked for.The conversion now normalizes a trailing
Zto+00:00, and only localizes when the parsed value is naive. An instant that already carries an offset is used as it is, which is what it means.test_clickup_client.pygains three cases. Because the manifest lane has nopytzwhile production does, they install a smallpytzstand-in whoselocalizerefuses an aware datetime exactly as pytz does, so the tests exercise the production path rather than the degraded one: aZdue date keeps its instant, an offset due date reaches ClickUp instead of being dropped, and a naive one still resolves. The first two fail on main.Failure-Class: none