SM DeprovisionAddOnTrialService: Same-day Pro purchase may end Enterprise trial unexpectedly
Bug
Summary
In #10054+, DeprovisionAddOnTrialService was created via !10972+, and logic was added with the intent to end a trial early/immediately if any Duo addon product is purchased after the trial begins.
However, there's some ambiguity here around the intended timing, and the definition of "after", especially in the event that the trial and the purchase take place on the same day.
def purchased_add_ons_after_trial_start?
relevant_add_ons_info.any? do |data|
data[:trial] == false && trial.start_date <= data[:started_on].to_date
end
end
Because the times are being compared as dates with no timestamp precision, there's no difference between "today at 00:01" and "today at 23:59"; they both get truncated to simply "today". Thus, an edge case may arise in which it's possible for an earlier Duo Pro purchase to prevent a later Duo Enterprise trial, even though the purchase was not "after".
eg
[8] pry(main)> pro_started = Time.now
=> 2025-08-04 11:01:24.138239191 -0400
[9] pry(main)> trial_started = Time.now
=> 2025-08-04 11:01:37.500818675 -0400
[10] pry(main)> trial_started <= pro_started
=> false
[11] pry(main)> trial_started.to_date <= pro_started.to_date
=> true
Therefore, a Pro purchase starting today will prevent a trial from also starting today even if the trial technically begins later. Considering that if the Enterprise trial were instead started next day, and it would then be allowed to continue for the full duration despite the Pro purchase, this ambiguity trends towards unintentional design.
Relatedly, even if this were intentional, the customer is informed through email that the Enterprise trial began successfully, but is otherwise given no indication that it ended nearly immediately thereafter, causing confusion.
Steps to reproduce
- Purchase Duo Pro for a subscription
- Begin a self-service Duo Enterprise trial within the same calendar day
What is the current bug behavior?
- A Duo Pro purchase prevents a Duo Enterprise trial from starting until the next calendar day
- This happens silently for the customer
Workarounds
- Probably a sales assisted $0 duo "trial"
Reported examples
Support Priority Score: (1, -, -, -, -, -, 3, -, 2, 2, -) => 8