From 02f5b78cb4c4fc73c1ae1010a31d28f8d68b9318 Mon Sep 17 00:00:00 2001 From: Abhisar Sinha <63767682+abh1sar@users.noreply.github.com> Date: Tue, 4 Aug 2026 21:22:34 +0530 Subject: [PATCH] Fix panic when serializing UUID-typed request parameters 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. --- cloudstack/AsyncjobService.go | 2 +- cloudstack/HostService.go | 4 ++-- cloudstack/ManagementService.go | 8 ++++---- cloudstack/WebhookService.go | 4 ++-- generate/generate.go | 4 +++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cloudstack/AsyncjobService.go b/cloudstack/AsyncjobService.go index fe29bc43..471289fb 100644 --- a/cloudstack/AsyncjobService.go +++ b/cloudstack/AsyncjobService.go @@ -60,7 +60,7 @@ func (p *ListAsyncJobsParams) toURLValues() url.Values { u.Set("listall", vv) } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } if v, found := p.p["page"]; found { vv := strconv.Itoa(v.(int)) diff --git a/cloudstack/HostService.go b/cloudstack/HostService.go index 16f9009b..f7d14e8c 100644 --- a/cloudstack/HostService.go +++ b/cloudstack/HostService.go @@ -2842,7 +2842,7 @@ func (p *ListHostsParams) toURLValues() url.Values { u.Set("keyword", v.(string)) } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } if v, found := p.p["name"]; found { u.Set("name", v.(string)) @@ -3546,7 +3546,7 @@ func (p *ListHostsMetricsParams) toURLValues() url.Values { u.Set("keyword", v.(string)) } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } if v, found := p.p["name"]; found { u.Set("name", v.(string)) diff --git a/cloudstack/ManagementService.go b/cloudstack/ManagementService.go index a8370f28..af4b6e52 100644 --- a/cloudstack/ManagementService.go +++ b/cloudstack/ManagementService.go @@ -58,7 +58,7 @@ func (p *CancelShutdownParams) toURLValues() url.Values { return u } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } return u } @@ -765,7 +765,7 @@ func (p *PrepareForShutdownParams) toURLValues() url.Values { return u } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } return u } @@ -838,7 +838,7 @@ func (p *ReadyForShutdownParams) toURLValues() url.Values { return u } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } return u } @@ -914,7 +914,7 @@ func (p *TriggerShutdownParams) toURLValues() url.Values { return u } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } return u } diff --git a/cloudstack/WebhookService.go b/cloudstack/WebhookService.go index 3b295cd1..c53f114b 100644 --- a/cloudstack/WebhookService.go +++ b/cloudstack/WebhookService.go @@ -458,7 +458,7 @@ func (p *DeleteWebhookDeliveryParams) toURLValues() url.Values { u.Set("id", v.(string)) } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } if v, found := p.p["startdate"]; found { u.Set("startdate", v.(string)) @@ -878,7 +878,7 @@ func (p *ListWebhookDeliveriesParams) toURLValues() url.Values { u.Set("keyword", v.(string)) } if v, found := p.p["managementserverid"]; found { - u.Set("managementserverid", v.(string)) + u.Set("managementserverid", string(v.(UUID))) } if v, found := p.p["page"]; found { vv := strconv.Itoa(v.(int)) diff --git a/generate/generate.go b/generate/generate.go index 7fbeb793..74d22c2d 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -1355,8 +1355,10 @@ func (s *service) generateConvertCode(cmd, name, typ string) { pn := s.pn switch typ { - case "string", "UUID": + case "string": pn("u.Set(\"%s\", v.(string))", name) + case "UUID": + pn("u.Set(\"%s\", string(v.(UUID)))", name) case "int": pn("vv := strconv.Itoa(v.(int))") pn("u.Set(\"%s\", vv)", name)