Skip to content

Comments

server: ignore projectid=-1 for finding owner#12695

Draft
shwstppr wants to merge 1 commit intoapache:4.20from
shapeblue:fix-failinglistpai-projid
Draft

server: ignore projectid=-1 for finding owner#12695
shwstppr wants to merge 1 commit intoapache:4.20from
shapeblue:fix-failinglistpai-projid

Conversation

@shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Feb 24, 2026

Description

Fixes #12693

projectid = -1 is used by UI and APIs to return entities from all projects. Therefore, it may make sense to ignore finding project for it when deducing entity owner.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Fixes apache#12693

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 16.25%. Comparing base (c748b69) to head (738ac0f).

Files with missing lines Patch % Lines
...c/main/java/com/cloud/user/AccountManagerImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #12695      +/-   ##
============================================
- Coverage     16.25%   16.25%   -0.01%     
  Complexity    13425    13425              
============================================
  Files          5662     5662              
  Lines        500155   500155              
  Branches      60738    60738              
============================================
- Hits          81319    81310       -9     
- Misses       409749   409759      +10     
+ Partials       9087     9086       -1     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.11% <0.00%> (-0.01%) ⬇️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland
Copy link
Contributor

@blueorangutan package

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where the UI is unable to list service offerings when the projects toggle button is enabled. The fix treats projectId=-1 as a special sentinel value (meaning "all projects") and skips project validation for this value in the finalizeOwner method.

Changes:

  • Modified finalizeOwner method to ignore projectId=-1 when determining entity owner
  • Reordered imports alphabetically (StringUtils and Ternary)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2562 to 2563
if ((accountName != null && domainId != null) && projectId != null) {
throw new InvalidParameterValueException("ProjectId and account/domainId can't be specified together");
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 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)

Copilot uses AI. Check for mistakes.
}

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