Skip to content

fix(backend): format the subscription reactivation billing date in UTC (#4643) - #8575

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
ZachL111:zach/payment-reactivation-billing-date-utc
Jun 29, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
ZachL111:zach/payment-reactivation-billing-date-utc

Conversation

@ZachL111

@ZachL111 ZachL111 commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

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_subscription in routers/payment.py built that date from Stripe's current_period_end (a Unix epoch) with a naive datetime.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.utc to datetime.fromtimestamp(...) so the date is computed in UTC. This matches how the same Stripe current_period_end field 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 in test.sh) is a source-level structural check, matching the other payment tests since routers/payment.py has a heavy import graph. It verifies timezone is imported and that the reactivation billing date is formatted with tz=timezone.utc. It fails against the previous naive code and passes with this change.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces labels Jun 29, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend bug fix with regression test; CI green. Approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants