Conversation
|
Great job! No new security vulnerabilities introduced in this pull request |
|
Claude finished @JaredScar's task in 5m 5s —— View job Re-Review: PR #6998 - PM-19232 Implement externalId handling in PatchUserCommand with validationReviewed commits since last review: Previous Findings Status
New Changes AnalysisThe latest commits correctly address all previously identified issues:
VerdictNo new issues found. All previously identified issues have been resolved. The PR is in good shape. Overall: Approve -- The implementation correctly handles externalId SCIM PATCH operations with proper validation (length, uniqueness), supports both path-based and value-object formats, and handles combined operations safely with the re-fetch pattern. |
| { | ||
| // Replace operations | ||
| if (operation.Op?.ToLowerInvariant() == "replace") | ||
| if (operation.Op?.ToLowerInvariant() == PatchOps.Replace) |
There was a problem hiding this comment.
Non-blocker: I know you're just following the existing pattern, so the code as is good, but consider abstracting this logic into its own method and using the early return pattern to reduce nested conditionals when possible.
// Replace operations
if (operation.Op?.ToLowerInvariant() == PatchOps.Replace)
{
// Active from path
if (operation.Path?.ToLowerInvariant() == "active")
{
var active = operation.Value.ToString()?.ToLowerInvariant();
var handled = await HandleActiveOperationAsync(orgUser, active == "true");
if (!operationHandled)
{
operationHandled = handled;
}
}
// Active from value object
else if (string.IsNullOrWhiteSpace(operation.Path) &&
operation.Value.TryGetProperty("active", out var activeProperty))
{
var handled = await HandleActiveOperationAsync(orgUser, activeProperty.GetBoolean());
if (!operationHandled)
{
operationHandled = handled;
}
}
// ExternalId from path
else if (operation.Path?.ToLowerInvariant() == PatchPaths.ExternalId)
{
var newExternalId = operation.Value.GetString();
await HandleExternalIdOperationAsync(orgUser, newExternalId);
operationHandled = true;
}
// ExternalId from value object
else if (string.IsNullOrWhiteSpace(operation.Path) &&
operation.Value.TryGetProperty("externalId", out var externalIdProperty))
{
var newExternalId = externalIdProperty.GetString();
await HandleExternalIdOperationAsync(orgUser, newExternalId);
operationHandled = true;
}
}Methods are normally used for DRY, but I think the ability to keep the scope small and let the method’s name provide a quick summary of what this group of code is doing makes it easier to understand at a glance. Also, the early return pattern makes it easier to follow.
JimmyVo16
left a comment
There was a problem hiding this comment.
Ping me again when you need a reapproval after fixing the tests.
…https://github.com/bitwarden/server into ac/pm-19232-entraID-reports-successful-PATCH-ops-fix
…ported operations instead of throwing exceptions. Update method names for clarity and adjust assertions in test cases accordingly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6998 +/- ##
==========================================
+ Coverage 56.67% 56.69% +0.01%
==========================================
Files 2013 2013
Lines 88131 88171 +40
Branches 7846 7856 +10
==========================================
+ Hits 49949 49987 +38
- Misses 36362 36363 +1
- Partials 1820 1821 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…alId properties from value objects, consolidating logic for improved clarity and maintainability.
JimmyVo16
left a comment
There was a problem hiding this comment.
The code is approved, but please make sure to add test coverage for all paths since it’s a complex method with many nested conditions.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…e characters and ensuring proper code structure.
… operations, ensuring accurate updates. Add corresponding test case to verify behavior when restoring users and updating externalId.
|




🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-19232
📔 Objective
Fit EntraID handling