Skip to content

fix(store): admin org search and kyc list skip soft-deleted orgs - #1974

Merged
rohilsurana merged 13 commits into
mainfrom
fix/admin-org-reads-skip-deleted
Oct 13, 2026
Merged

rohilsurana merged 13 commits into
mainfrom
fix/admin-org-reads-skip-deleted

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What changes

  • The admin org search and the org kyc list now skip soft-deleted organizations.
  • The admin org search skips deleted billing accounts and subscriptions. The check is inside the join conditions, so a live org whose account is deleted stays in the list with no plan and no payment mode.

Why

These queries read straight from organizations and the billing tables with no live filter. Once the org delete is soft, a deleted org or a deleted account would still show up. The billing part matters once the billing deletes become soft in #1983.

Stack

This PR is stacked on #1984 (kyc row soft delete). Merge #1984 first.

Tests

  • kyc list: a soft-deleted org is absent, a live one is present.
  • admin org search: the SQL includes the live filter, and a database test checks a soft-deleted org is absent from the search.
  • admin org search with billing: an org whose only account is deleted is still listed with no plan or payment mode. An org with a live account and a deleted subscription is listed with the payment mode but no plan. Live rows are unchanged.

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
frontier Ready Ready Preview Oct 13, 2026 7:56am UTC

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: raystack/frontier/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 693582be-cbb2-410a-b0ca-0754f5434a16
📥 Commits

Reviewing files that changed from the base of the PR and between dc70da4 and b4929de.

📒 Files selected for processing (5)
  • internal/store/postgres/kyc_repository.go
  • internal/store/postgres/kyc_repository_test.go
  • internal/store/postgres/org_billing_repository.go
  • internal/store/postgres/org_billing_repository_pg_test.go
  • internal/store/postgres/org_billing_repository_test.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: raystack/frontier/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 860c1b31-4a7e-4da6-9419-4ae13d541c79
📥 Commits

Reviewing files that changed from the base of the PR and between 0789141 and dc70da4.

📒 Files selected for processing (5)
  • internal/store/postgres/kyc_repository.go
  • internal/store/postgres/kyc_repository_test.go
  • internal/store/postgres/org_billing_repository.go
  • internal/store/postgres/org_billing_repository_pg_test.go
  • internal/store/postgres/org_billing_repository_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Organization KYC listings now exclude organizations that have been soft-deleted.
    • Organization billing searches and related results exclude soft-deleted organizations, billing customers, and subscriptions. Payment mode remains available when a subscription has been soft-deleted.

KYC listing now excludes soft-deleted organizations. Organization billing searches exclude soft-deleted organizations, billing customers, and subscriptions. Repository and PostgreSQL integration tests cover these filters and the returned billing details.

Changes: KYC live-organization listing

Layer / File(s) Summary
KYC listing filter and test
internal/store/postgres/kyc_repository.go, internal/store/postgres/kyc_repository_test.go
List now builds its query from live organizations. A test verifies that the result contains only the live organization.

Live organization billing queries

Layer / File(s) Summary
Billing filters and validation
internal/store/postgres/org_billing_repository.go, internal/store/postgres/org_billing_repository_test.go, internal/store/postgres/org_billing_repository_pg_test.go
The billing query now filters soft-deleted organizations, customers, and subscriptions. SQL expectations and PostgreSQL integration tests cover these filters and the returned billing details.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: whoabhisheksah

Merge Risk: ⚪ Minimal · up to dc70d

The changes appear ready to merge after normal checks; no actionable issue remains from this review.

Pre-merge checks · Passed 2
Passed Passed checks (2 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 Oct 7, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 38363645868

Coverage increased (+0.1%) to 54.857%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 7 of 7 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 41521
Covered Lines: 22777
Line Coverage: 54.86%
Coverage Strength: 18.8 hits per line

💛 - Coveralls

@AmanGIT07

Copy link
Copy Markdown
Contributor

Billing account and subscription deletes become soft in #1983, and this search is the last billing list that doesn't skip deleted rows. So a live org can show a deleted account's plan and payment mode, for example after an org delete that stops half way. Can we add live(TABLE_BILLING_CUSTOMERS) and live(TABLE_BILLING_SUBSCRIPTIONS) inside the two join On clauses, the way org_serviceuser_repository.go does? It needs to be in On, not Where, or a live org whose only account is deleted drops out of the list.

The kyc join is fine as of now, since the kyc delete still removes the row. The kyc row should also move to soft delete, like the other tables the org delete touches. Can we do that, and add live(TABLE_ORGANIZATIONS_KYC) inside this join's On in the same change? Without that check, an org delete that stops after the kyc step would leave a live org that still shows its old kyc status and link here.

@rohilsurana
rohilsurana force-pushed the fix/admin-org-reads-skip-deleted branch from 0789141 to 1155d62 Compare October 12, 2026 12:17
@rohilsurana
rohilsurana changed the base branch from main to feat/kyc-soft-delete October 12, 2026 12:17
@rohilsurana

Copy link
Copy Markdown
Member Author

Done in 1155d62. The billing account and subscription joins now check deleted_at inside the join On, so a live org whose account is deleted stays in the list with no plan. The kyc part is in #1984, which makes the kyc delete soft and adds the same check to the kyc list join. I stacked this PR on #1984, so that one should merge first.

@rohilsurana
rohilsurana force-pushed the fix/admin-org-reads-skip-deleted branch from 8ced8e5 to 2b47e3b Compare October 12, 2026 13:14
@rohilsurana
rohilsurana force-pushed the fix/admin-org-reads-skip-deleted branch from 2b47e3b to 7c6880e Compare October 13, 2026 06:10
Base automatically changed from feat/kyc-soft-delete to main October 13, 2026 07:17
@rohilsurana
rohilsurana merged commit 7d1a3d3 into main Oct 13, 2026
8 checks passed
@rohilsurana
rohilsurana deleted the fix/admin-org-reads-skip-deleted branch October 13, 2026 08:04

This branch was successfully deployed

1 active deployment
Preview — b4929de3 Deployed Oct 13, 2026 by vercel[bot]
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