Skip to content

Breaking change in v2.19.0 in GetNetworkID for CloudStack versions < 4.22 #140

Description

@hrak

In version 2.19.0 GetNetworkID was changed to use name instead of keyword for searching networks by name.

This broke backwards compatibility for CloudStack versions older than 4.22, which are not aware of the name parameter of the listNetworks API.

The following functions are affected:

  • GetNetworkID
  • GetNetworkByName

Activity

  1. hrak commented on Apr 13, 2026

    @hrak
    Author

    I briefly looked into fixing this but i can't really find a way to determine the version within the client to use as a conditional. Would be good to have a client.Version() or something to retrieve the current CloudStack version we're connecting with.

  2. added this to the 2.20.0 milestone on May 19, 2026
  3. jmsperu commented on Jun 20, 2026

    @jmsperu
    Contributor

    Looked into this. The root cause is in the generator: when a list<X> API exposes both name and keyword string params, the Get<X>ID/Get<X>ByName emitter now prefers name (generate/generate.go — if p.Name == "name" ... return "name" takes precedence over the keyword branch). listNetworks has both, so post-2.19.0 it searches by name, which CloudStack < 4.22 rejects.

    Two ways forward:

    A. Fallback (version-agnostic, smallest change). Search by name; if the call fails with an unknown-parameter error (what < 4.22 returns for name), retry with keyword. No version logic, works everywhere; the only cost is one extra call on the legacy path.

    B. Version-aware (addresses the blocker @hrak hit). A client.Version() is actually feasible today — listCapabilities returns it, and the SDK already models it: Capability.Cloudstackversion (ConfigurationService.go). A small lazily-cached helper (call ListCapabilities once, parse cloudstackversion, memoize on the client) gives a CloudStackVersion() primitive, after which GetNetworkID can branch name (>= 4.22) vs keyword (older). This is reusable well beyond networks, since the generator’s name-preference change affects every Get<X>ID whose list API gained a name param.

    My suggestion: ship A as the immediate backward-compat fix, and add B as the general primitive (it’s broadly useful and is the clean long-term answer). Happy to put up a PR for either/both once a maintainer signals a preference — I have a 4.22 environment to test against.

  4. modified the milestones: 2.20.0, 2.19.1 on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions