fix(acl): keep the account whitelist in the update response - #4122
Conversation
updateUser's merge builder preserves every existing field it re-reads (id, accessKey, secretKey, admin, clusters, gmtCreate) but drops whiteRemoteAddress, so the API response after a harmless rename reports the IP whitelist as gone. The stored row survives (updateById skips null columns), yet the update endpoint's reply - and anything the caller derives from it - loses the value. Carry it through the merge. Signed-off-by: zjncs <18910855655@163.com>
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Fixes a field omission in AclService.updateUser where whiteRemoteAddress was not carried through the merge builder, causing the API to respond with null after a harmless rename even though the stored row was preserved. One-line fix. LGTM.
Automated review by RockteMQ-AI
…ate (#4113) Two ACL account defects, folded into one change because they touch the same account read/write path. `toPlainAccessConfig` read an account's rules through `ruleQuery()`, whose principal filter is a substring `LIKE`. Accounts whose access keys contain one another were merged: reading `svc-a` also returned the rules of `svc-a-v2`, and because `upsertPlainAccessRules` deletes by exact principal before writing, the absorbed rules were written back verbatim onto the wrong account. The read now uses an exact `eq("principal", ...)` wrapper with the same ordering, mirroring the delete. `AclService.updateUser` merged the incoming account onto the stored one but never carried `whiteRemoteAddress` across, so the update response reported a null whitelist even though `replaceUser` does not write that column at all. The web ACL page replaces its local row with that response without refetching, so the whitelist visibly disappeared until the next reload. The merged builder now keeps the existing value. Folded in from #4122, which made the same one-line whitelist fix independently; that PR is closed as superseded by this one.
|
Closing as folded into #4113, which was merged into Your diagnosis and your fix here were correct and are now on the branch: The reason this landed inside #4113 rather than on its own: both PRs fix the same ACL account read/write path, arrived within an hour of each other from the same author, and neither touches a file the other does. We group related same-author changes into one commit on the target PR so the branch history stays readable, and #4113 was the target here. Your Nothing further needed from you — thank you for the fix and for the precise write-up of why a null whitelist in the response is user-visible rather than cosmetic. |
Motivation
AclService.updateUser(local plain-access path) carefully preserves every existing field of the account through a partial update —accessKey,secretKey,admin,clusters,gmtCreate— but the merge builder omitswhiteRemoteAddress:whiteRemoteAddressis a real, persisted field of local plain-access accounts (rmq_acl_user.white_remote_address, written bycreateAndUpdatePlainAccessConfig, read back bytoUserVO). The stored row survives the update (MyBatis-PlusupdateByIdskips null columns), butreplaceUserreturns the merged VO, soPOST /api/acl/users/updateresponds withwhiteRemoteAddress: nullafter a harmless rename — the API reports the account's IP whitelist as gone even though it is still enforced.Modifications
Carry
existing.getWhiteRemoteAddress()through the merge, like every other preserved field.Verification
New test
updateUserShouldKeepTheExistingWhiteRemoteAddress(model:updateUserShouldSaveExistingUser): existing user withwhiteRemoteAddress = "10.0.1.0/24", rename via DTO.whiteRemoteAddressin the response isnull.mvn -f server/pom.xml test -Dtest='AclServiceTest,MybatisPlusAclRepositoryTest,AclControllerTest'→ Tests run: 114, Failures: 0, Errors: 0.