This is an automated email from the ASF dual-hosted git repository.

abh1sar pushed a commit to branch fix-uuid-request-param-serialization
in repository https://gitbox.apache.org/repos/asf/cloudstack-go.git

commit 02f5b78cb4c4fc73c1ae1010a31d28f8d68b9318
Author: Abhisar Sinha <[email protected]>
AuthorDate: Tue Aug 4 21:22:34 2026 +0530

    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 fe29bc4..471289f 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 16f9009..f7d14e8 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 a8370f2..af4b6e5 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 3b295cd..c53f114 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 7fbeb79..74d22c2 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)

Reply via email to