Repository navigation
fix(backend): format the subscription reactivation billing date in UTC (#4643) - #8575
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. The code change looks correct: formatting Stripe's current_period_end with tz=timezone.utc avoids host-local timezone drift in the reactivation success message, and it matches the UTC handling used elsewhere for subscription period-end timestamps. The added regression coverage is also scoped to this behavior and the repo checks are passing.
I’m leaving this as a positive maintainer signal rather than a formal approval because this touches the backend payment/billing path and the PR is linked to another issue/sequence, so a human maintainer should still do the final review before merge. No agent-instruction or AI behavior documentation is changed.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the focused fix here. The code change itself looks directionally correct to me: formatting Stripe's current_period_end with tz=timezone.utc makes the reactivation message consistent with the UTC handling used elsewhere, while leaving the raw epoch response unchanged.
A couple of maintainer notes:
- The added regression coverage is a source-level structural test rather than an end-to-end behavioral test, but that seems reasonable for this narrow payment-router path given the heavier import graph.
- Because this touches backend payment/subscription behavior and the PR is already marked
security-review/needs-maintainer-review, I’m intentionally not formally approving it. A human maintainer should do the final payment/security review before merge.
No blocking code issue found from my static review.
kodjima33
left a comment
There was a problem hiding this comment.
Backend bug fix with regression test; CI green. Approving.
Problem
When a user reactivates a subscription that was scheduled to cancel, the confirmation message tells them when their plan renews:
"Your subscription has been reactivated! No charge now - your plan will automatically renew on {next_billing}."
_try_reactivate_subscriptioninrouters/payment.pybuilt that date from Stripe'scurrent_period_end(a Unix epoch) with a naivedatetime.fromtimestamp(...), which interprets the timestamp in the host's local timezone. On any host not running in UTC the rendered day can be off by one.Fix
Pass
tz=timezone.utctodatetime.fromtimestamp(...)so the date is computed in UTC. This matches how the same Stripecurrent_period_endfield is already formatted elsewhere in the codebase (utils/subscription.py,database/users.py).Only the displayed date string changes. The raw epoch is still returned unchanged as
next_billing_date, so no caller that relies on the numeric value is affected.Test
tests/unit/test_payment_reactivation_billing_date_utc.py(registered intest.sh) is a source-level structural check, matching the other payment tests sincerouters/payment.pyhas a heavy import graph. It verifiestimezoneis imported and that the reactivation billing date is formatted withtz=timezone.utc. It fails against the previous naive code and passes with this change.