Fix incorrect parameter order in deleteSubSubAttribute call#457
Conversation
| case 2: | ||
| newUser.deleteSubSubAttribute(baseAttributeName, subAttributes[0], subAttributes[1]); | ||
| newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
| case 2: | |
| newUser.deleteSubSubAttribute(baseAttributeName, subAttributes[0], subAttributes[1]); | |
| newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName); | |
| case 2: | |
| if (log.isDebugEnabled()) { | |
| log.debug("Deleting sub-sub-attribute: " + subAttributes[1] + " from " + subAttributes[0] + " in " + baseAttributeName); | |
| } | |
| newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName); |
| break; | ||
| case 2: | ||
| newUser.deleteSubSubAttribute(baseAttributeName, subAttributes[0], subAttributes[1]); | ||
| newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 2
| newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName); | |
| newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Deleted sub-sub attribute: " + subAttributes[1] + "." + subAttributes[0] + "." + baseAttributeName); | |
| } |
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
| Comment | Accepted (Y/N) | Reason |
|---|---|---|
| #### Log Improvement Suggestion No: 1 | ||
| #### Log Improvement Suggestion No: 2 |
WalkthroughFixed argument ordering in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #457 +/- ##
=========================================
Coverage 31.93% 31.93%
Complexity 1112 1112
=========================================
Files 137 137
Lines 13524 13524
Branches 2589 2589
=========================================
Hits 4319 4319
Misses 8667 8667
Partials 538 538
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/MeResourceManager.java (1)
317-318:⚠️ Potential issue | 🟠 MajorAdd null guard before
isEmpty()on line 379.
UserResourceManager.updateWithPATCH(...)checkssyncedAttributes == nullbefore accessing the map, butMeResourceManagercallsisEmpty()directly without a null guard. Although the interface default returns a non-nullHashMap, implementations could override and returnnull. Line 379 will throw aNullPointerExceptionif that occurs.Apply the same null check used in
UserResourceManager:if (syncedAttributes == null) { continue; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/MeResourceManager.java` around lines 317 - 318, MeResourceManager calls userManager.getSyncedUserAttributes() into syncedAttributes and then uses syncedAttributes.isEmpty(), which can NPE if an implementation returns null; add the same null guard used in UserResourceManager.updateWithPATCH by checking "if (syncedAttributes == null) { continue; }" before calling isEmpty() so deletedSyncedAttributes handling skips when syncedAttributes is null.
🧹 Nitpick comments (1)
modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/UserResourceManager.java (1)
741-741: Add a regression test for this positional delete path.The same child/parent/grandParent mix-up landed in both resource managers, so a focused PATCH test for synced nested-attribute removal would make this much harder to regress.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/UserResourceManager.java` at line 741, Add a focused regression test that reproduces the positional delete path for synced nested-attribute removal: create a user with nested multi-valued attributes, perform a PATCH that removes a grandchild attribute using the positional path that triggers UserResourceManager.deleteSubSubAttribute (and the analogous method in the other resource manager), then assert the correct nested attribute was removed (and no parent/child mix-up occurred). Ensure the test covers the exact invocation pattern that led to the bug (positional indices in the path), uses the same request parsing code path as production, and verifies both server-side stored state and the response.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/MeResourceManager.java`:
- Around line 317-318: MeResourceManager calls
userManager.getSyncedUserAttributes() into syncedAttributes and then uses
syncedAttributes.isEmpty(), which can NPE if an implementation returns null; add
the same null guard used in UserResourceManager.updateWithPATCH by checking "if
(syncedAttributes == null) { continue; }" before calling isEmpty() so
deletedSyncedAttributes handling skips when syncedAttributes is null.
---
Nitpick comments:
In
`@modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/UserResourceManager.java`:
- Line 741: Add a focused regression test that reproduces the positional delete
path for synced nested-attribute removal: create a user with nested multi-valued
attributes, perform a PATCH that removes a grandchild attribute using the
positional path that triggers UserResourceManager.deleteSubSubAttribute (and the
analogous method in the other resource manager), then assert the correct nested
attribute was removed (and no parent/child mix-up occurred). Ensure the test
covers the exact invocation pattern that led to the bug (positional indices in
the path), uses the same request parsing code path as production, and verifies
both server-side stored state and the response.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 99a557bf-2e18-4711-89ac-fee351fe06f8
📒 Files selected for processing (2)
modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/MeResourceManager.javamodules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/UserResourceManager.java
Purpose
-$Subject
Related Issue
Summary by CodeRabbit
Bug Fixes
Chores