Repository navigation
Deleting a Cloud workspace releases its trial; a live subscription blocks the deletion - #894
Merged
Merged
Conversation
A deleted workspace's licence row was left with organization_id NULL and the licence site never heard of the deletion: trials kept getting reminder and win-back emails, and card trials went on to their first charge. The deletion paths now release the orphaned licences (the site cancels the subscription and revokes the licence), and the onboarding cron retries what the site did not confirm. The delete dialogs say the plan ends with the workspace.
Subscriptions are cancelled by the customer in the Stripe billing portal only. Deleting a workspace (or an account with its workspaces) is refused while a subscription Stripe would charge again is live; once it is set to cancel, the deletion goes through and only trials are released. The delete dialogs are back to their previous wording.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Deleting a workspace (or an account, together with its own workspaces) left the licence row with
organization_id NULL(ON DELETE SET NULL), and the licence site never found out. In production right now there are 44 active trials and 53 expired trials of deleted workspaces that keep getting reminder and win-back emails.Changes
LicenseReleaseService.assertNoLiveSubscription: in Cloud, beforedeleteOrganizationand beforedeleteSelf(for the workspaces deleted with the account), it asks the licence site (/api/license/verify?billing=1, service token) for the subscription's state. If Stripe would charge again (trialing/active/past_due/unpaid, not set to cancel), deletion is refused with 409 and a pointer to Settings → License → Manage subscription & billing. If the site cannot be reached, it uses the last known state, or refuses with "try again" when there is none./api/license/release, which revokes trials. When the site confirms (or answers with the route's own JSON 404), the local row is deleted. A refusal (e.g. a subscription still running until period end) marks the rowinvalid. A failure leaves it for the next onboarding cron run, which also backfills the existing orphans. Only one pass runs at a time, and it is a no-op on self-hosted. The module is separate to avoid the LicenseModule ↔ UsersModule cycle.Deploy website HelpCode-ai/anythingmcp-website#310 first. Even in the wrong order nothing is lost: only the route's own 404 drops a row.
Tests
license-release.service.spec.ts, deletion tests in users/organizations, and the cron spec. Full jest: 6712 passed. The only failure is the HANA suite (hdbis missing locally), unrelated.