Fix list response keys derived from the API name - #162
Open
abh1sar wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes silent decode failures in generated List*Response wrappers by using a curated listResponseKeys map (observed from real CloudStack servers) instead of deriving list item keys from the API name, and adds regression tests to prevent reintroducing the mismatches. It also makes the getRawValue empty-array guard survive regeneration by moving it into the generator.
Changes:
- Replace per-API switch arms with a single
listResponseKeysoverride map +listResponseKey()fallback ingenerate/generate.go. - Add/extend regression tests to assert list wrapper keys observed from real servers (including two single-object/no-count responses).
- Regenerate affected service response structs to use the correct JSON tags (and change
listCaCertificate/listUsageServerMetricsto pointer fields to match on-wire shape).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| generate/generate.go | Introduces listResponseKeys + listResponseKey() and moves the getRawValue empty-array guard into codegen output. |
| test/ListResponseJSONTagsRegression_test.go | Adds regression coverage for newly observed list wrapper keys and the two single-object/no-count responses. |
| cloudstack/ASNumberRangeService.go | Fixes list wrapper tag for listASNRanges (asnumberrange). |
| cloudstack/BackupService.go | Fixes list wrapper tag for listBackupProviders (providers). |
| cloudstack/CertificateService.go | Updates listCaCertificate response to a single-object pointer field under cacertificates. |
| cloudstack/ClusterService.go | Fixes list wrapper tag for listClustersMetrics (cluster). |
| cloudstack/ExtensionService.go | Fixes list wrapper tag for listCustomActions (extensioncustomaction). |
| cloudstack/FirewallService.go | Fixes list wrapper tag for listRoutingFirewallRules (firewallrule). |
| cloudstack/HostService.go | Fixes list wrapper tag for listHostsMetrics (host). |
| cloudstack/NetworkService.go | Fixes list wrapper tags for listNetworkIsolationMethods (isolationmethod) and listSupportedNetworkServices (networkservice). |
| cloudstack/SystemVMService.go | Fixes list wrapper tag for listSystemVmsUsageHistory (virtualmachine). |
| cloudstack/UsageService.go | Fixes list wrapper tag for listTrafficTypeImplementors and updates listUsageServerMetrics to a single-object pointer field under usageMetrics. |
| cloudstack/UserService.go | Fixes list wrapper tag for listUserTwoFactorAuthenticatorProviders (providers). |
| cloudstack/VolumeService.go | Fixes list wrapper tag for listVolumesMetrics (volume). |
| cloudstack/ZoneService.go | Fixes list wrapper tags for listIpv4SubnetsForZone (zoneipv4subnet) and listZonesMetrics (zone). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
CloudStack keys a list response's items by the response object name, not by the API name the generator derived the tag from, so 16 list APIs decoded as a permanently empty slice while count parsed from the same body and no error was returned. The keys are now data in a documented listResponseKeys map rather than 24 hand-written switch arms, each one observed on a real server and pinned by a test, leaving only genuine shape differences in the switch; listCaCertificate and listUsageServerMetrics also become pointers, since they return a single object with no count. Also moves the getRawValue empty-array guard from #154 into the generator, where it had been edited into the generated file only and so was reverted by every `make code`.
abh1sar
force-pushed
the
fix-list-response-keys
branch
from
August 11, 2026 13:43
e847e5d to
1db12bd
Compare
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.
CloudStack keys a list response's items by the response object name, not by the API name the generator derived the tag from, so 16 list APIs decoded as a permanently empty slice while count parsed from the same body and no error was returned.
The keys are now data in a documented listResponseKeys map rather than 24 hand-written switch arms, each one observed on a real server and pinned by a test, leaving only genuine shape differences in the switch; listCaCertificate and listUsageServerMetrics also become pointers, since they return a single object with no count.
Also moves the getRawValue empty-array guard from #154 into the generator, where it had been edited into the generated file only and so was reverted by every
make code