Uh oh!
There was an error while loading. Please reload this page.
NPE correction when informing removed project in the listProjectRoles - #13022
NPE correction when informing removed project in the listProjectRoles#13022Tonitzpp wants to merge 2 commits into
listProjectRoles#13022Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## 4.22 #13022 +/- ##
============================================
- Coverage 17.67% 17.67% -0.01% + Complexity 15792 15786 -6
============================================
Files 5922 5922 Lines 533123 533125 +2 Branches 65201 65201 ============================================
- Hits 94246 94240 -6 - Misses 428236 428240 +4 - Partials 10641 10645 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
Fixes a NullPointerException triggered by calling the listProjectRoles API with a projectid that refers to a removed project, changing the behavior to return a parameter error instead of crashing.
Changes:
- Update
ProjectRoleManagerImpl.findProjectRolesto return an empty list whenprojectIdis null (instead of returning null). - Add explicit project existence validation in
ListProjectRolesCmd.execute()and throwInvalidParameterValueExceptionwhen the project cannot be found.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| server/src/main/java/org/apache/cloudstack/acl/ProjectRoleManagerImpl.java | Prevents null list returns from findProjectRoles when projectId is null. |
| api/src/main/java/org/apache/cloudstack/api/command/admin/acl/project/ListProjectRolesCmd.java | Validates the project exists before listing roles and throws a parameter exception when not found. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
listProjectRolesThere was a problem hiding this comment.
Pull request overview
This PR aims to prevent a NullPointerException in the listProjectRoles API when the caller provides a projectid for a removed/non-existent project, changing the behavior to return a clear parameter error instead.
Changes:
- Validate the provided
projectIdinListProjectRolesCmd.execute()and throw anInvalidParameterValueExceptionwhen the project can’t be found. - Avoid per-role project lookup when building
ProjectRoleResponseby passing the project UUID through the response setup method. - Adjust
ProjectRoleManagerImpl.findProjectRoles()to return an empty list whenprojectIdis null (instead of returningnull).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
server/src/main/java/org/apache/cloudstack/acl/ProjectRoleManagerImpl.java | Returns an empty list when projectId is null to reduce NPE risk from null list returns. |
api/src/main/java/org/apache/cloudstack/api/command/admin/acl/project/ListProjectRolesCmd.java | Adds project existence validation and avoids NPE when a project has been removed by not dereferencing a null project during response building. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
DaanHoogland
commented
Apr 28, 2026
@blueorangutan package |
blueorangutan
commented
Apr 28, 2026
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Pull request overview
Fixes an NPE in the listProjectRoles API when a removed project is supplied as projectid, by validating project existence up-front and avoiding repeated project lookups while building responses.
Changes:
- Validate the provided project ID in
ListProjectRolesCmd.execute()and throw anInvalidParameterValueExceptionwhen the project can’t be found. - Avoid calling
_projectService.getProject(...).getUuid()per role by reusing the resolved project UUID. - Adjust
ProjectRoleManagerImpl.findProjectRolesto return an empty list fornullproject IDs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| server/src/main/java/org/apache/cloudstack/acl/ProjectRoleManagerImpl.java | Changes project-role listing behavior for null/invalid project IDs (now returns empty list for null). |
| api/src/main/java/org/apache/cloudstack/api/command/admin/acl/project/ListProjectRolesCmd.java | Adds explicit project existence validation and avoids the per-role project lookup that caused the NPE. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
blueorangutan
commented
Apr 28, 2026
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 17630 |
sureshanaparti
commented
Apr 29, 2026
@Tonitzpp can you check the build failure. |
Uh oh!
There was an error while loading. Please reload this page.
DaanHoogland
commented
May 7, 2026
@blueorangutan package |
blueorangutan
commented
May 7, 2026
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
blueorangutan
commented
May 7, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17749 |
Uh oh!
There was an error while loading. Please reload this page.
weizhouapache
commented
May 7, 2026
@Tonitzpp |
63f0803 to
f1e0864CompareDaanHoogland
commented
May 20, 2026
@blueorangutan package |
blueorangutan
commented
May 20, 2026
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
blueorangutan
commented
May 20, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17929 |
DaanHoogland
commented
May 21, 2026
@blueorangutan test |
blueorangutan
commented
May 21, 2026
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
blueorangutan
commented
May 21, 2026
[SF] Trillian Build Failed (tid-16145) |
blueorangutan
commented
May 23, 2026
[SF] Trillian test result (tid-16157)
|
Description
Currently, when using the
listProjectRolesAPI, passing theprojectidparameter of a removed project results in an NPE. This PR changes this behavior to return the messageFailed to find project by IDinstead.Types of changes
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
Before the changes
After the changes
How Has This Been Tested?
To perform the tests, a test project was created along with a project role. The project was deleted and the
listProjectRolesAPI was called passing the ID of the project role. This showed the new message.