Skip to content

Fix list response keys derived from the API name - #162

Open
abh1sar wants to merge 1 commit into
mainfrom
fix-list-response-keys
Open

Fix list response keys derived from the API name#162
abh1sar wants to merge 1 commit into
mainfrom
fix-list-response-keys

Conversation

@abh1sar

@abh1sar abh1sar commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI lite review requested due to automatic review settings August 11, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 listResponseKeys override map + listResponseKey() fallback in generate/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 / listUsageServerMetrics to 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.

Comment thread generate/generate.go Outdated
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`.
Copilot AI review requested due to automatic review settings August 11, 2026 13:43
@abh1sar
abh1sar force-pushed the fix-list-response-keys branch from e847e5d to 1db12bd Compare August 11, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants