shwstppr opened a new pull request, #13480:
URL: https://github.com/apache/cloudstack/pull/13480

   ### Description
   
   Fixes NPE observed when calling resetPasswordForVirtualMachine API for an 
expunged VM.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] 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?
   
   Before:
   
   ```
   (localcloud) 🐱 > reset passwordforvirtualmachine 
id=6aa8552f-a0ca-4520-9359-c26e06c22e4c
   {
     "account": "admin1",
     "accountid": "7ef3edd8-b4ca-46b4-97d0-e7bebeb8704d",
     "cmd": 
"org.apache.cloudstack.api.command.admin.vm.ResetVMPasswordCmdByAdmin",
     "completed": "2026-06-24T05:01:50+0000",
     "created": "2026-06-24T05:01:30+0000",
     "domainid": "cc89a62c-6a12-11f1-bcb1-525400491d42",
     "domainpath": "ROOT",
     "jobid": "6725d884-236b-4482-b96b-964a54b6b5ea",
     "jobinstanceid": "6aa8552f-a0ca-4520-9359-c26e06c22e4c",
     "jobinstancetype": "VirtualMachine",
     "jobprocstatus": 0,
     "jobresult": {
       "errorcode": 530,
       "errortext": "Cannot invoke \"com.cloud.uservm.UserVm.getUuid()\" 
because \"vm\" is null"
     },
     "jobresultcode": 530,
     "jobresulttype": "object",
     "jobstatus": 2,
     "userid": "7c01a5fa-8d06-402a-8932-e6673470ac6b"
   }
   ```
   
   ```
   2026-06-24 05:01:50,231 ERROR [c.c.a.ApiAsyncJobDispatcher] 
(API-Job-Executor-6:[ctx-463637d6, job-16856]) (logid:6725d884) Unexpected 
exception while executing 
org.apache.cloudstack.api.command.admin.vm.ResetVMPasswordCmdByAdmin 
java.lang.NullPointerException: Cannot invoke 
"com.cloud.uservm.UserVm.getUuid()" because "vm" is null
        at 
org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd.execute(ResetVMPasswordCmd.java:123)
        at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:173)
        at 
com.cloud.api.ApiAsyncJobDispatcher.runJob(ApiAsyncJobDispatcher.java:110)
        at 
org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.runInContext(AsyncJobManagerImpl.java:649)
        at 
org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49)
        at 
org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
        at 
org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
        at 
org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
        at 
org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
        at 
org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.run(AsyncJobManagerImpl.java:597)
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)
   ```
   
   After:
   ```
   (localcloud) 🐱 > reset passwordforvirtualmachine 
id=6aa8552f-a0ca-4520-9359-c26e06c22e4c
   {
     "account": "admin1",
     "accountid": "7ef3edd8-b4ca-46b4-97d0-e7bebeb8704d",
     "cmd": 
"org.apache.cloudstack.api.command.admin.vm.ResetVMPasswordCmdByAdmin",
     "completed": "2026-06-24T05:17:43+0000",
     "created": "2026-06-24T05:17:43+0000",
     "domainid": "cc89a62c-6a12-11f1-bcb1-525400491d42",
     "domainpath": "ROOT",
     "jobid": "eeb141fa-93f2-49b5-9af7-3aed32f5184e",
     "jobinstanceid": "6aa8552f-a0ca-4520-9359-c26e06c22e4c",
     "jobinstancetype": "VirtualMachine",
     "jobprocstatus": 0,
     "jobresult": {
       "errorcode": 431,
       "errortext": "unable to find an Instance with id 5"
     },
     "jobresultcode": 431,
     "jobresulttype": "object",
     "jobstatus": 2,
     "userid": "7c01a5fa-8d06-402a-8932-e6673470ac6b"
   }
   🙈 Error: async API failed for job eeb141fa-93f2-49b5-9af7-3aed32f5184e
   ```
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to 
-->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- Please read the 
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) 
document -->
   


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

Reply via email to