Fix panic when serializing UUID-typed request parameters - #160
Merged
Conversation
generateConvertCode treated the generated "UUID" Go type the same as "string" when building toURLValues(), emitting v.(string) for a value that is actually stored as cloudstack.UUID. That type assertion panics at runtime since Go requires an exact dynamic type match. Affects managementserverid, currently the only parameter routed through the UUID type, on listAsyncJobs, listHosts, listHostsMetrics, triggerShutdown, cancelShutdown, prepareForShutdown, listWebhookDeliveries, and deleteWebhookDelivery. It was previously dormant since the parameter is optional on all of them and the setter was never exercised by the standard generated tests. Assert the value as UUID and convert to string, instead of asserting it as string.
abh1sar
requested review from
Pearl1594 and
sureshanaparti
and
a lite review from Copilot
August 4, 2026 16:03
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes a runtime panic when serializing UUID-typed request parameters by generating correct toURLValues() conversion code for UUID values.
Changes:
- Update generator to treat
UUIDdistinctly fromstringwhen emitting URL value conversion code. - Regenerate affected service files so
managementserveridis serialized viastring(v.(UUID)).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| generate/generate.go | Fixes generator logic to avoid invalid string type assertion for UUID. |
| cloudstack/WebhookService.go | Regenerated: serializes managementserverid as UUID -> string. |
| cloudstack/ManagementService.go | Regenerated: serializes managementserverid as UUID -> string. |
| cloudstack/HostService.go | Regenerated: serializes managementserverid as UUID -> string. |
| cloudstack/AsyncjobService.go | Regenerated: serializes managementserverid as UUID -> string. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generateConvertCodein the generator treats the generatedUUIDGo type the same asstringwhen buildingtoURLValues(), emittingv.(string)for a value that is actually stored ascloudstack.UUID. Since Go type assertions require an exact dynamic type match, this panics at runtime for any parameter whose Go type isUUID.Currently
managementserveridis the only parameter routed through theUUIDtype (via thelongToStringConvertedParamsmap), and it's used onlistAsyncJobs,listHosts,listHostsMetrics,triggerShutdown,cancelShutdown,prepareForShutdown,listWebhookDeliveries, anddeleteWebhookDelivery. This has been dormant so far becausemanagementserveridis optional on all of these commands, so the setter is never exercised by the standard generated tests, but it panics on every real call that actually sets it.Fix: assert the value as
UUIDand convert tostring, instead of asserting it asstring:Regenerated the affected service files (
AsyncjobService.go,HostService.go,ManagementService.go,WebhookService.go); no other diff.Testing
Tested against a real CloudStack installation, calling
listHosts,listHostsMetrics, andlistAsyncJobswithmanagementserveridset (the three read-only commands among the affected list; skippedtriggerShutdown/cancelShutdown/prepareForShutdownsince those actually change the management server's shutdown state).Before:
After: