Fix manual lock grace period bug#6503
Merged
Merged
Conversation
47e6a9d to
29845e3
Compare
zoldar
approved these changes
Jul 14, 2026
zoldar
left a comment
Contributor
There was a problem hiding this comment.
Nice work explaining all the context of this tricky bug 👏
|
|
||
| def active?(%{grace_period: %__MODULE__{manual_lock: true}}) do | ||
| true | ||
| def active?(%{grace_period: %__MODULE__{manual_lock: true}} = team) do |
Contributor
There was a problem hiding this comment.
Would it make sense to move that clause to the top, so it always takes precedence over anything else? 🤔
Contributor
Author
There was a problem hiding this comment.
Yes, I think it would. Although it wouldn't make a functional difference (because end date being a %Date{} and manual_lock being true are be mutually exclusive), a manual lock grace period getting an end date by mistake sounds more probable than a grace period randomly becoming manual_lock: true. 84b9943
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
The bug is caused by
Plausible.GracePeriod.active?/1unconditionally returningtruefor anymanual_lockgrace_period. It should returnfalsewhen the manual lock grace period has been terminated manually via CS.The bug is pretty tricky, so I'll do my best explaining what happens under the hood:
grace_period.is_over = truesite_locker.exruns -- checks every team and ends up callingPlausible.Teams.Billing.check_needs_to_upgrade/2check_needs_to_upgradeends up returning:no_upgrade_neededbecause theTeams.GracePeriod.expired?(team)cond branch wrongly returnsfalsesite_locker.exunlocks the site but keeps the grace period in placeAt this point, we're already in a messed up state because on one hand, the team is unlocked, but on the other, it has a manually terminated grace period. Now we get to rendering
usage_notificationfor the team in the team settings billing section:usage_notification_typetries to find the type of the notification to renderTeams.GracePeriod.expired?(team)returns false (also mentioned above)manual_lock_active?returns false as well -- this is correct becauseis_overbeingtruemeans it's not activeGracePeriod.active?returns true (the root bug)usage_notificationcomponent then tries to render "days left" but no case clause matchesnil-- amanual_lockgrace period hasend_date = nilExpected behaviour:
:dashboard_lockedTests
Changelog
Documentation
Dark mode