Skip to content

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Oct 24, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Added capability to remove ABAC attributes from rooms.
  • Improvements

    • Enhanced attribute management to prevent invalid empty states and streamline cascading removals.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 24, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

⚠️ No Changeset found

Latest commit: d3ad2ea

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

This 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

Cohort / File(s) Summary
ABAC Service Guards
ee/packages/abac/src/index.ts
Added guards in setRoomAbacAttributes to unset attributes if the provided object is empty, and in removeRoomAbacAttribute to unset all attributes if removing would leave the room with none.
Room Model Interface
packages/model-typings/src/models/IRoomsModel.ts
Added new public method signature unsetAbacAttributesById(rid: IRoom['_id']): Promise<UpdateResult> to the IRoomsModel interface.
Room Model Implementation
packages/models/src/models/Rooms.ts
Implemented unsetAbacAttributesById(_id: IRoom['_id']) method in RoomsRaw class to unset abacAttributes field via MongoDB $unset operation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • d-gubert
  • lucas-a-pelegrino
  • tassoevan

Poem

🐰 Hop along, the attributes do dance,
When they're empty, we give them a glance,
A guard here, an unset right there,
Cleanup is love, cleanup is care! 🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "chore: Unset attributes instead of leaving empty array" directly captures the primary objective of the changeset. The modifications across all three files are focused on implementing logic to unset ABAC attributes when they become empty rather than leaving them as empty arrays. The title is concise, specific, and clearly communicates the behavioral change introduced by the pull request. A teammate scanning the commit history would understand that this change addresses how empty attribute collections are handled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/unset

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 and usage tips.

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.09%. Comparing base (5e9962a) to head (d3ad2ea).
⚠️ Report is 2 commits behind head on feat/abac.

Additional details and impacted files

Impacted file tree graph

@@            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           
Flag Coverage Δ
e2e 57.40% <ø> (+<0.01%) ⬆️
unit 71.66% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KevLehman KevLehman marked this pull request as ready for review October 24, 2025 19:54
@KevLehman KevLehman requested a review from a team as a code owner October 24, 2025 19:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5e9962a and d3ad2ea.

📒 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 $unset operator to remove the abacAttributes field from room documents, preventing empty arrays from being stored. The implementation follows established patterns in the codebase and is properly positioned alongside the complementary setAbacAttributesById method.

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.

@tassoevan tassoevan merged commit 38bc363 into feat/abac Oct 24, 2025
49 checks passed
@tassoevan tassoevan deleted the chore/unset branch October 24, 2025 20:02
@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 3, 2025
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