Skip to content

feat(deleter): serve CheckOrganizationDelete for delete eligibility - #1894

Merged
whoAbhishekSah merged 1 commit into
org-delete-check-protofrom
org-delete-check-api
Aug 24, 2026
Merged

feat(deleter): serve CheckOrganizationDelete for delete eligibility#1894
whoAbhishekSah merged 1 commit into
org-delete-check-protofrom
org-delete-check-api

Conversation

@whoAbhishekSah

@whoAbhishekSah whoAbhishekSah commented Aug 18, 2026

Copy link
Copy Markdown
Member

Part of #1837. Top of the stack, based on #1893. Proto: raystack/proton#499.

The product decision for the delete button: disabled while any of the three blockers exist (active subscription on a paid plan, unpaid invoice, negative token balance), enabled on the unused-tokens case and the happy path. The client cannot compute the paid-plan case itself — it does not know the server's configured standard plan — so this adds a read-only check RPC.

CheckOrganizationDelete returns the same blocker list that DeleteOrganization's failed_precondition carries, without changing anything. Each blocker has type (the reason), subject (the blocking entity's id), subject_type (what kind of entity that id is: billing_subscription, billing_invoice, or billing_account), and message.

  • No subscription gets canceled (the delete only cancels standard-plan subscriptions once everything else is clear).
  • Invoice rows are read as they are — no forced provider sync per check, since clients may call this on every settings page view. The answer is advisory; the delete still re-checks against fresh provider data.
  • Requires the same delete permission on the org as the delete itself.
  • A missing org returns not_found.

The SDK will switch its delete button to this RPC once the proton npm package ships with it; until then #1881 greys the button on the invoice case only.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview Aug 24, 2026 8:23am

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 719f2937-c0f9-4fd1-9684-4be3b6f6a6ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Aug 18, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32705926072

Coverage increased (+0.05%) to 49.131%

Details

  • Coverage increased (+0.05%) from the base build.
  • Patch coverage: 18 uncovered changes across 3 files (88 of 106 lines covered, 83.02%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
core/deleter/service.go 83 70 84.34%
pkg/server/connect_interceptors/authorization.go 4 0 0.0%
internal/api/v1beta1connect/deleter.go 19 18 94.74%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
core/deleter/service.go 1 80.28%

Coverage Stats

Coverage Status
Relevant Lines: 40522
Covered Lines: 19909
Line Coverage: 49.13%
Coverage Strength: 15.7 hits per line

💛 - Coveralls

@whoAbhishekSah
whoAbhishekSah force-pushed the org-delete-check-api branch 2 times, most recently from 9d0516e to 4aa1165 Compare August 18, 2026 06:52

@rohilsurana rohilsurana 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.

Stack-aware review (base org-delete-check-proto). Main thing is the check vs delete mismatch below; the other two are small. I dropped an earlier note about the NotFound mapping: it is only reachable for non-existent orgs, which a real client will not hit.

Comment thread core/deleter/service.go Outdated
Comment thread core/deleter/service.go
Comment thread core/deleter/service.go Outdated

@rohilsurana rohilsurana 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.

Re-review after the fix commits. The err-before-loop fix and the shared paidPlans/balances cache both look good, and the negative-total case now lines up. I left the credit-covered greying alone since you already flagged it as a deferred, safe-direction gap. Two small cleanup/doc notes.

Comment thread core/deleter/service.go Outdated
Comment thread core/deleter/deleter.go Outdated
Clients need to know whether an org delete would go through before the
user tries it — for example to grey out the delete button and say why.
CheckOrganizationDelete returns the same blocker list the delete's
failed_precondition carries (paid-plan subscription, unpaid invoice,
negative token balance) without changing anything: no subscription gets
canceled and the invoice rows are read as they are. The answer is
advisory; DeleteOrganization still re-checks against fresh provider
data. The RPC requires the same delete permission on the org.
@whoAbhishekSah
whoAbhishekSah merged commit 35c1688 into main Aug 24, 2026
12 of 13 checks passed
@whoAbhishekSah
whoAbhishekSah deleted the org-delete-check-api branch August 24, 2026 08:30
whoAbhishekSah added a commit that referenced this pull request Aug 24, 2026
The delete button now asks the server directly whether a delete would
go through (CheckOrganizationDelete, added in #1894)
instead of inferring one blocker from the invoice list. The button
greys out for every blocker the real delete would refuse with — a paid
subscription to downgrade, unpaid invoices, a token debt — and the
tooltip shows one short instruction per kind of blocker, with counts
for invoices and a fallback to the server's message for kinds this
version does not know. While the check loads the button stays disabled;
a failed check fails open since the server refuses independently.

@raystack/proton moves to the proton main commit that ships the RPC.
The shared open-invoice filters stay for the billing page's
payment-issue banner.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants