refactor(api): drop per-handler org-state checks covered by the gate - #1867
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughSummary by CodeRabbit
WalkthroughDomain, group, and invitation handlers no longer enforce organization enabled-state checks for selected operations. Listing handlers use raw organization lookups. Tests now match the updated service interactions. A shared organization validation helper was added. ChangesOrganization state handler updates
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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. Comment |
Org-state enforcement lives on the authorization path now, so the redundant per-handler checks are removed. List handlers resolve the org state-blind with GetRaw; create handlers keep blocking disabled orgs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4991ad9 to
bc573f9
Compare
Coverage Report for CI Build 31390964691Coverage increased (+0.2%) to 48.097%Details
Uncovered Changes
Coverage Regressions419 previously-covered lines in 13 files lost coverage.
Coverage Stats
💛 - Coveralls |
Summary
With the disabled-org gate on the authorization path (#1860), org-state enforcement now lives in one place. This removes the per-handler org-state checks that the gate makes redundant, so the gate is the single source of truth for org state.
Changes
GetGroup,UpdateGroup,ListGroupUsers,RemoveGroupUser,SetGroupMemberRole,DisableGroup) andEnableGroup: drop the per-handler org-state check.getGroupInEnabledOrgbecomesgetGroup— it still loads the group and maps a disabled or missing group toNotFound, without checking org state.DeleteOrganizationDomain,GetOrganizationDomain,VerifyOrganizationDomainand invitationGetOrganizationInvitation,DeleteOrganizationInvitation: remove the org-state pre-check. Domain ownership stays enforced in the interceptor.ListOrganizationGroups,ListOrganizationDomains,ListOrganizationInvitations: resolve the org withGetRaw(state blind) to get its id; the gate enforces state.CreateGroup,CreateOrganizationDomain,CreateOrganizationInvitation: keeporgService.Get, so a disabled org blocks creation withFailedPrecondition.ensureOrgEnabledintoorg_state.go, alongside the gate and PAT checks that use it.Technical Details
getGroup; the gate resolves groups withIncludeDisabledso re-enable still works.AuthTokenandJoinOrganizationkeep their own org checks — they are on the authorization skip list, so the gate does not run for them.Behavior changes
PermissionDenied(permission is checked first) rather thanFailedPrecondition.Test Plan
make testpassesmake e2e-testpasses