Repository navigation
fix: make ESP delete work and explain why a delete is blocked (#12) - #163
Merged
Merged
Conversation
…ory (#12) Delete now answers 409 with a reason code (esp_is_default, esp_has_delivery_history, esp_retire_instead, delivery_source_in_use) instead of silently deleting a team's live default or reporting every blocker as delivery_source_in_use. Activated drafts can be retired, MCP gains retire_esp, and blocked/organization deletes go to PostHog.
#12) Settings keeps the confirm dialog open with the reason a delete is blocked and adds Retire. The organization page offered Retire for drafts and Delete for retired mailboxes, both of which the API always refused; it now offers Delete for never-activated drafts and Retire otherwise.
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.
Closes #12. Part of #152.
Root cause
The original redirect. When #12 was filed,
needsTeamSelection()inapps/web/lib/tokens.tstreated every 409 as "pick a team". So when the API refused a delete with409 delivery_source_in_use, the browser was sent to/teams. 81c0d72 narrowed that check tono_team/team_required, andtokens.test.tsalready covers409 delivery_source_in_use. Onmainthe redirect no longer happens. I confirmed this in a browser before changing any code.Delete was still broken in other ways, all reproduced on
main:invalid_lifecycle_transition. It offered Delete only for retired mailboxes, which the API also always refused (its documented rule is that only a never-activated draft is deleted). The toast then said the mailbox was "still assigned to a team" even when it was not.delivery_source_in_use. That included an ESP with old, already-sent transactional email, which can never be deleted, and one with a delivery-feedback connection. The reason appeared in a banner at the top of the page, and the confirmation dialog closed.Fix
A blocked delete now returns a 409 with a code that says why. Delivery history is never deleted.
esp_is_defaultdelivery_source_in_useesp_has_delivery_historyesp_retire_insteadAlertDialog).retire_esptool, added to the parity manifest.delete_espanddelete_esp_configreturn the same reasons as the API.esp_config_delete_blocked(withreason) andorganization_esp_deleted. I addedesp_idtoPROPERTY_ALLOWLIST. It was missing, soesp_config_removedhad been dropping it.docs/organizations.md.Tests
bun run lint,format:checkandtypecheckall pass.--parallel).check:driftandtest:conformancepass.retire_espBrowser e2e (Playwright, fresh DB, API :5150 / web :3150)
All 17 checks passed, with no navigation away from the page at any point:
esp_retire_insteadfor it.