1fanwang opened a new pull request, #164: URL: https://github.com/apache/cloudstack-go/pull/164
## Summary On CloudStack before 4.22, looking up a missing network name can return an unrelated network's ID. Those servers ignore the name filter introduced in SDK 2.19.0. The generator now sends `keyword` alongside `name` for network lookups. This fixes both `GetNetworkID` and `GetNetworkByName` while retaining exact-name filtering on newer servers. Fixes: https://github.com/apache/cloudstack-go/issues/140 ## Testing Done I ran the committed CI subtest against official CloudStack 4.21.0.0 and 4.22.1.0 simulators with real MySQL. The existing CI setup creates the network and VMs through the API; no database rows or API responses are fabricated. | # | Scenario | Command | Result | |---|---|---|---| | 1 | Missing network on 4.21, before fix | CI command below | Returned another network's ID | | 2 | Same lookup after fix | Same command | No-match error, count 0 | | 3 | Existing and missing names on 4.22 | Same command on port 18072 | Correct ID or no match | <details><summary>Raw logs</summary> With CLOUDSTACK_API_KEY and CLOUDSTACK_SECRET_KEY set to the simulator credentials used by the existing CI workflow: ```sh export CLOUDSTACK_API_URL=http://127.0.0.1:18172/client/api go test -mod=readonly -count=1 -v ./ci -run '^TestCloudstackAPI$/^NetworkNameLookups$' ``` Before, on 4.21: ```text ci_test.go:110: GetNetworkID("missing-7d4d2975-1c50-4631-b2bb-4340ac96fc1a"): id="7d4d2975-1c50-4631-b2bb-4340ac96fc1a" count=1 error=<nil> ci_test.go:120: GetNetworkByName("missing-7d4d2975-1c50-4631-b2bb-4340ac96fc1a"): id="7d4d2975-1c50-4631-b2bb-4340ac96fc1a" count=1 error=<nil> ``` After, on 4.21: ```text ci_test.go:110: GetNetworkID("missing-87a41ce9-87ef-4352-853a-9159b0be8226"): id="" count=0 error=No match found for missing-87a41ce9-87ef-4352-853a-9159b0be8226: &{Count:0 Networks:[]} ci_test.go:120: GetNetworkByName("missing-87a41ce9-87ef-4352-853a-9159b0be8226"): id="" count=0 error=No match found for missing-87a41ce9-87ef-4352-853a-9159b0be8226: &{Count:0 Networks:[]} ``` The same subtest on 4.22: ```text --- PASS: TestCloudstackAPI/NetworkNameLookups (0.52s) ``` </details> The HTTP regression also covers multiple matches and option forwarding. -- 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]
