Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/src/main/java/com/cloud/user/AccountManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
import com.cloud.utils.ConstantTimeComparator;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.StringUtils;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.Manager;
import com.cloud.utils.component.ManagerBase;
Expand Down Expand Up @@ -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) {
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id=" + projectId);
Expand Down
Loading