Skip to content

server/myaccount: exclude deleted OUs from ListMyOrgUnits (#183)#189

Merged
Prabhjot-Sethi merged 1 commit into
go-core-stack:mainfrom
dev-arya23:feature/183-filter-deleted-ous-myaccount
Jun 27, 2026
Merged

server/myaccount: exclude deleted OUs from ListMyOrgUnits (#183)#189
Prabhjot-Sethi merged 1 commit into
go-core-stack:mainfrom
dev-arya23:feature/183-filter-deleted-ous-myaccount

Conversation

@dev-arya23

@dev-arya23 dev-arya23 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Filter out soft-deleted org-units (deleted > 0) from the user-facing /api/myaccount/v1/org-units endpoint while keeping the internal ListOrgUnits API inclusive.

Changes

  • pkg/server/myaccount.go: ListMyOrgUnits now skips entries where Deleted > 0 in both code paths:
    • Non-admin path: after fetching each OU via ouTable.Find(), skip if soft-deleted
    • Admin path: in the FindByTenant loop, skip if soft-deleted
  • Default-OU selection fixed to use len(resp.Items) == 0 instead of loop index i == 0 — ensures the first active (non-deleted) OU becomes the default, not the first iteration which may be a deleted entry that gets skipped
  • Internal ListOrgUnits in pkg/server/org-unit.go is not modified — continues returning all OUs including deleted ones for admin tooling and internal service visibility
  • No behavior change when allow_ou_delete is disabled (no deleted OUs exist)

Refs: #183

…ack#183)

Filter out soft-deleted org-units (deleted > 0) from the user-facing
myaccount list endpoint in both admin and non-admin code paths.

The internal ListOrgUnits API continues returning all OUs including
deleted ones so that admin tooling and internal services retain full
visibility.

Also fix default-OU selection to use the first active (non-deleted) OU
rather than the first iteration index, which could point to a deleted
entry when the filter skips it.

Refs: go-core-stack#183

Signed-off-by: Dev Arya <dev-arya23@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@dev-arya23, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 5 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdff813a-14a0-4aa7-95d6-672936c09c0c

📥 Commits

Reviewing files that changed from the base of the PR and between 7bbd8c4 and d19dac3.

📒 Files selected for processing (1)
  • pkg/server/myaccount.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Prabhjot-Sethi Prabhjot-Sethi merged commit 4b17d12 into go-core-stack:main Jun 27, 2026
1 of 3 checks passed
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.

2 participants