Copilot commented on code in PR #12695:
URL: https://github.com/apache/cloudstack/pull/12695#discussion_r2845505208
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -2563,7 +2563,7 @@ public Account finalizeOwner(Account caller, String
accountName, Long domainId,
throw new InvalidParameterValueException("ProjectId and
account/domainId can't be specified together");
}
- if (projectId != null) {
+ if (projectId != null && projectId != -1L) {
Review Comment:
The change to handle projectId=-1 lacks test coverage. Consider adding tests
to AccountManagerImplTest.java that verify the behavior when projectId=-1 is
passed to finalizeOwner. Tests should cover scenarios such as:
1. When projectId=-1 is passed alone, it should not throw an "Unable to find
project" exception
2. When projectId=-1 is passed with accountName and domainId, it should not
throw the "ProjectId and account/domainId can't be specified together" exception
3. The method should return the caller account when projectId=-1 is passed
without other parameters
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -2563,7 +2563,7 @@ public Account finalizeOwner(Account caller, String
accountName, Long domainId,
throw new InvalidParameterValueException("ProjectId and
account/domainId can't be specified together");
Review Comment:
The validation at line 2562 should also exclude projectId=-1 to be
consistent with the fix at line 2566. When projectId=-1 is passed (indicating
"all projects"), it should not conflict with specifying accountName and
domainId together, since -1 is a special sentinel value rather than an actual
project identifier. The condition should be updated to:
if ((accountName != null && domainId != null) && projectId != null &&
projectId != -1L)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]