Remove UUID parse from param processing workflow#13065
Remove UUID parse from param processing workflow#13065erikbocks wants to merge 2 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores compatibility with resources whose stored “UUID” identifiers are not RFC-compliant UUID strings by removing strict UUID parsing/validation from the API parameter translation workflow and by treating stored UUIDs as opaque strings in the call context.
Changes:
- Stop parsing/validating resource UUIDs with
UUID.fromString(...)during parameter translation; store raw identifier strings instead. - Change
CallContextAPI-resource UUID storage fromUUIDtoString, and simplifyBaseCmd#getResourceUuid()accordingly. - Update affected unit tests to use
StringUUIDs when populatingCallContext.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java | Stores raw resource identifier strings in CallContext during UUID→ID translation (removes UUID.fromString parsing). |
| api/src/main/java/org/apache/cloudstack/context/CallContext.java | Changes apiResourcesUuids map value type from UUID to String and updates getter/setter signatures. |
| api/src/main/java/org/apache/cloudstack/api/BaseCmd.java | Simplifies getResourceUuid() to return the raw string from CallContext (removes UUID conversion/validation). |
| api/src/test/java/org/apache/cloudstack/api/command/user/network/routing/DeleteRoutingFirewallRuleCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/test/UpdateConditionCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/test/CreateSnapshotCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/volume/UnmanageVolumeCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/storage/DownloadImageStoreObjectCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/UpdateBgpPeerCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/ReleaseDedicatedBgpPeerCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/DeleteBgpPeerCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/DedicateBgpPeerCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/CreateBgpPeerCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/ChangeBgpPeersForVpcCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/bgp/ChangeBgpPeersForNetworkCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/UpdateIpv4SubnetForZoneCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedIpv4SubnetForZoneCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/DeleteIpv4SubnetForZoneCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/DeleteIpv4SubnetForGuestNetworkCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/DedicateIpv4SubnetForZoneCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/CreateIpv4SubnetForZoneCmdTest.java | Updates test to store a string UUID in CallContext. |
| api/src/test/java/org/apache/cloudstack/api/command/admin/network/CreateIpv4SubnetForGuestNetworkCmdTest.java | Updates test to store a string UUID in CallContext. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| CallContext.current().putApiResourceUuid(annotation.name(), uuid); | ||
| CallContext.current().putContextParameter(entity, uuid); |
There was a problem hiding this comment.
The change to store raw String UUIDs (including non-RFC UUID values) in CallContext is not covered by unit tests. Please add/extend a ParamProcessWorkerTest case that exercises translateUuidToInternalId with a non-UUID resource identifier (e.g., an entity whose Identity#getUuid returns a non-UUID string) and asserts that parameter processing completes and the value is available via BaseCmd#getResourceUuid/CallContext#getApiResourceUuid.
| CallContext.current().putApiResourceUuid(annotation.name(), uuid); | |
| CallContext.current().putContextParameter(entity, uuid); | |
| String entityUuid = uuid; | |
| if (objVO instanceof Identity) { | |
| entityUuid = ((Identity)objVO).getUuid(); | |
| } | |
| CallContext.current().putApiResourceUuid(annotation.name(), entityUuid); | |
| CallContext.current().putContextParameter(entity, internalId); |
|
@blueorangutan package |
|
@winterhazel 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17593 |

Description
PR #12502 introduced a generic method to retrieve untranslated UUIDs received as command parameters, without having to query the database during the command processing workflow. A validation using
UUID.parseStringwas included before storing them in the context to ensure that they were valid UUIDs. However, it was previously possible to set the UUID of some entities to values that are not valid UUIDs, which got broken by this validation.This PR removes the validation in order to support back the usage of arbitrary values as resource UUIDs.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
After changing the code, I built it with Maven and validated that no error occurred during the build. The unit tests were not skipped for the build process.
After installing the packages with the changes to my environment, I created a account with
nonuuidvalueas its UUID. Then, I listed the registered accounts with thelistAccountsAPI. With this, I validated that the error from parsing theidattribute value was fixed.listAccountsAPI resultI also validated that the UUID obtention for events description was not affected by the changes. In order to test this, I disabled two different accounts: the one with the
nonuuidvaluevalue as UUID, and an account that I created for this test. After inspecting the events, it was possible to validate that the resources' UUIDs were still being displayed correctly.Events description