Skip to content

Fix incorrect parameter order in deleteSubSubAttribute call#457

Merged
AfraHussaindeen merged 1 commit intowso2:masterfrom
AfraHussaindeen:master_sub-sub-deletefix
Apr 3, 2026
Merged

Fix incorrect parameter order in deleteSubSubAttribute call#457
AfraHussaindeen merged 1 commit intowso2:masterfrom
AfraHussaindeen:master_sub-sub-deletefix

Conversation

@AfraHussaindeen
Copy link
Copy Markdown
Contributor

@AfraHussaindeen AfraHussaindeen commented Mar 30, 2026

Purpose

-$Subject

Related Issue

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the parameter order for nested sub-attribute deletion operations during PATCH requests to ensure sub-attributes are properly identified and removed at the correct hierarchy levels. Updates applied across multiple resource management components to maintain consistent and reliable attribute handling behavior.
  • Chores

    • Updated copyright year range and organization information in file headers.

Comment on lines 402 to +403
case 2:
newUser.deleteSubSubAttribute(baseAttributeName, subAttributes[0], subAttributes[1]);
newUser.deleteSubSubAttribute(subAttributes[1], subAttributes[0], baseAttributeName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 2

Suggested change
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);
}

Copy link
Copy Markdown

@wso2-engineering wso2-engineering bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Walkthrough

Fixed argument ordering in deleteSubSubAttribute method calls for PATCH-based migrated attribute deletion across two resource manager classes. The parameter sequence for base and sub-attribute names was reversed in nested deletion operations. Updated copyright headers from 2016/Wso2 Inc. to 2016-2026/WSO2 LLC.

Changes

Cohort / File(s) Summary
Attribute Deletion Logic Updates
modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/MeResourceManager.java, modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/UserResourceManager.java
Corrected argument order in deleteSubSubAttribute calls from (baseAttributeName, subAttributes[0], subAttributes[1]) to (subAttributes[1], subAttributes[0], baseAttributeName), inverting the treatment of base vs. sub-level attribute names during nested attribute deletion operations. Updated copyright year range to 2016-2026.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With whiskers twitched and careful hop,
I sorted attributes top to toe,
Base and sub went 'round about,
Arguments rearranged, no doubt—
The deletion dance now flows just so! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete, missing most required sections including Goals, Approach, User stories, Developer Checklist, Release notes, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Migrations, Test environment, and Learning. Complete the pull request description by filling in the missing required sections from the repository template, particularly Goals, Approach, and test coverage information.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: fixing the parameter order in deleteSubSubAttribute calls across two files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 31.93%. Comparing base (76f6f7a) to head (297790b).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...3/core/protocol/endpoints/UserResourceManager.java 0.00% 1 Missing ⚠️
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           
Flag Coverage Δ
unit 31.06% <50.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

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

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 | 🟠 Major

Add null guard before isEmpty() on line 379.

UserResourceManager.updateWithPATCH(...) checks syncedAttributes == null before accessing the map, but MeResourceManager calls isEmpty() directly without a null guard. Although the interface default returns a non-null HashMap, implementations could override and return null. Line 379 will throw a NullPointerException if 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

📥 Commits

Reviewing files that changed from the base of the PR and between 76f6f7a and 297790b.

📒 Files selected for processing (2)
  • modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/MeResourceManager.java
  • modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/UserResourceManager.java

@AfraHussaindeen AfraHussaindeen merged commit 75c6e9b into wso2:master Apr 3, 2026
5 checks passed
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.

2 participants