-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: Unset attributes instead of leaving empty array #37301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughThis PR introduces ABAC attribute cleanup mechanisms by adding guards to unset room attributes when they become empty during management operations, and adds a corresponding model method to unsetting ABAC attributes by room ID. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/abac #37301 +/- ##
==========================================
Coverage 70.09% 70.09%
==========================================
Files 3032 3032
Lines 103981 103987 +6
Branches 18491 18493 +2
==========================================
+ Hits 72887 72894 +7
+ Misses 29144 29143 -1
Partials 1950 1950
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
ee/packages/abac/src/index.ts (1)
345-349: Consider enhancing the comment for clarity.The guard correctly unsets all attributes when removing the last one, preventing an empty array from being stored. However, the comment could be more explicit about the rationale.
Apply this diff to improve the comment:
- // if is the last attribute, just remove all + // If this is the last attribute, unset the field entirely to avoid storing an empty array if (previous.length === 1) { await Rooms.unsetAbacAttributesById(rid); return; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
ee/packages/abac/src/index.ts(2 hunks)packages/model-typings/src/models/IRoomsModel.ts(1 hunks)packages/models/src/models/Rooms.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/model-typings/src/models/IRoomsModel.ts (1)
packages/core-typings/src/IRoom.ts (1)
IRoom(22-98)
packages/models/src/models/Rooms.ts (1)
packages/core-typings/src/IRoom.ts (1)
IRoom(22-98)
🔇 Additional comments (3)
packages/models/src/models/Rooms.ts (1)
1964-1966: LGTM! Clean implementation of the unset operation.The method correctly uses MongoDB's
$unsetoperator to remove theabacAttributesfield from room documents, preventing empty arrays from being stored. The implementation follows established patterns in the codebase and is properly positioned alongside the complementarysetAbacAttributesByIdmethod.ee/packages/abac/src/index.ts (1)
187-190: Good guard to prevent storing empty arrays.This early return ensures that when an empty attributes object is provided, the field is properly unset from the room document rather than storing an empty array. The behavior is consistent with the intent that rooms without ABAC attributes should revert to normal private groups.
packages/model-typings/src/models/IRoomsModel.ts (1)
320-320: LGTM! Well-positioned interface signature.The method signature is correctly defined and appropriately placed adjacent to
setAbacAttributesById, clearly indicating these are complementary operations. The type signature matches the implementation in the Rooms model.
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit
New Features
Improvements