Skip to content

[PM-32699] Utilize cache to check ability of useMyItems if available#7922

Open
JaredScar wants to merge 1 commit into
mainfrom
ac/pm-32699-remove-temp-workarounds-in-consuming-code
Open

[PM-32699] Utilize cache to check ability of useMyItems if available#7922
JaredScar wants to merge 1 commit into
mainfrom
ac/pm-32699-remove-temp-workarounds-in-consuming-code

Conversation

@JaredScar

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-32699

📔 Objective

Uses useMyItems flag from cache if available, otherwise if null/miss, falls back to checking on the Organization model

…ization ability cache

- Added IOrganizationAbilityCacheService to the constructor for improved performance.
- Replaced direct organization repository calls with cache lookups in UpsertDefaultCollectionsForUsersAsync.
- Introduced OrganizationUsesMyItemsAsync method to streamline cache access and fallback logic.
- Updated tests to accommodate the new cache service and ensure correct behavior under various scenarios.
@JaredScar JaredScar requested a review from a team as a code owner July 2, 2026 22:06
@JaredScar JaredScar requested a review from eliykat July 2, 2026 22:06
@JaredScar JaredScar added ai-review Request a Claude code review t:tech-debt Change Type - Tech debt labels Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the tech-debt change in OrganizationDataOwnershipPolicyEventHandler that removes the temporary GetByIdAsync workaround and reads UseMyItems from IOrganizationAbilityCacheService, falling back to the organization repository on a cache miss. Verified DI wiring (ExtendedOrganizationAbilityCacheService registered as the implementation), the null-miss fallback path, and the exception behavior when the organization is not found. The three new unit tests cover the cache-hit-enabled, cache-hit-disabled, and cache-miss branches, and existing tests correctly default the cache substitute to a miss.

No blocking issues found.

Code Review Details

No findings. The change is focused, correctly wired, and well covered by tests. The registered ExtendedOrganizationAbilityCacheService uses a read-through GetOrSetAsync, so the handler's explicit repository fallback only executes on a genuine null result — a safe, defensive design consistent with the ticket scope.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.36%. Comparing base (e899a9c) to head (6fe12c7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7922   +/-   ##
=======================================
  Coverage   61.35%   61.36%           
=======================================
  Files        2236     2236           
  Lines       98547    98554    +7     
  Branches     8911     8912    +1     
=======================================
+ Hits        60468    60476    +8     
+ Misses      35943    35942    -1     
  Partials     2136     2136           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

Comment on lines +81 to +87
var organization = await organizationRepository.GetByIdAsync(organizationId);
if (organization == null)
{
throw new InvalidOperationException($"Organization with ID {organizationId} not found.");
}

return organization.UseMyItems;

@eliykat eliykat Jul 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary - we're doing this cleanup work because the cache has been fixed and we can rely on it. Please remove this and throw a NotFoundException instead if the org isn't in the cache.

@eliykat eliykat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants