abh1sar opened a new pull request, #160:
URL: https://github.com/apache/cloudstack-go/pull/160
## Summary
`generateConvertCode` in the generator treats 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`. Since Go type assertions
require an exact dynamic type match, this panics at runtime for any parameter
whose Go type is `UUID`.
Currently `managementserverid` is the only parameter routed through the
`UUID` type (via the `longToStringConvertedParams` map), and it's used on
`listAsyncJobs`, `listHosts`, `listHostsMetrics`, `triggerShutdown`,
`cancelShutdown`, `prepareForShutdown`, `listWebhookDeliveries`, and
`deleteWebhookDelivery`. This has been dormant so far because
`managementserverid` is 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 `UUID` and convert to `string`, instead of
asserting it as `string`:
```go
case "string":
pn("u.Set(\"%s\", v.(string))", name)
case "UUID":
pn("u.Set(\"%s\", string(v.(UUID)))", name)
```
Regenerated the affected service files (`AsyncjobService.go`,
`HostService.go`, `ManagementService.go`, `WebhookService.go`); no other diff.
## Manual testing
- `go build ./...`: clean.
- `go test ./test/... ./examples/...`: all 151 existing tests pass, no
regressions.
- `make mocks`: zero diff, mock signatures unaffected.
- Added a temporary local test directly exercising
`TriggerShutdownParams.toURLValues()` with a `UUID`-typed `managementserverid`
value: panicked before this fix, passed and returned the correct string after.
Not committed, since it required an unexported-method test in the `cloudstack`
package outside the generated pattern.
## Test plan
- [ ] CI passes
- [ ] Reviewer confirms no other parameters currently route through the
`UUID` type
--
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]