Fix network name lookups on older CloudStack servers - #164
Open
1fanwang wants to merge 2 commits into
Open
Conversation
Send keyword alongside name so older servers filter network lookups while newer servers retain exact-name matching. Fixes: apache#140 Signed-off-by: 1fanwang <1fannnw@gmail.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Validate the returned name for single partial matches and add regression coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes CloudStack pre-4.22 network name lookups by sending keyword alongside name.
Changes:
- Updates generated and network service lookup code.
- Adds HTTP regression coverage.
- Adds simulator-backed CI scenarios.
Review finding: single partial keyword matches still require exact-name validation.
File summaries
| File | Description |
|---|---|
test/GetNetworkByNameRegression_test.go |
Tests legacy and current lookup behavior. |
generate/generate.go |
Generates the legacy-compatible keyword fallback. |
cloudstack/NetworkService.go |
Applies keyword to network ID lookups. |
ci/ci_test.go |
Adds simulator-backed lookup coverage. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Require the requested name to match the sole keyword candidate before returning its ID. apache#164 (comment) Signed-off-by: 1fanwang <1fannnw@gmail.com>
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.
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
keywordalongsidenamefor network lookups. BothGetNetworkIDandGetNetworkByNamerequire an exact name, even when the keyword search returns only one candidate.Fixes: #140
Testing Done
I ran the committed CI subtest against CloudStack 4.21.0.0 with real MySQL. It creates a network and VMs through the API and exercises exact, absent, and partial names. HTTP regressions also cover the newer server's exact-name filter.
Raw logs
With CLOUDSTACK_API_KEY and CLOUDSTACK_SECRET_KEY set to the simulator credentials used by the existing CI workflow:
Before, on ad15f21 with the added regression:
After, on 4.21:
The HTTP regression also covers multiple matches and option forwarding.