Skip to content

prefix field is null but not marked as optional in Ip dataclass [Instance] #1040

@jychp

Description

@jychp

Description

When calling list_ips_all() to retrieve the list of IPs for my instances, the following code fails with a TypeError:

api = InstanceV1API(client)
return api.list_ips_all(organization=org_id, zone=DEFAULT_ZONE)

The error traceback is:

TypeError: Ip.__init__() missing 1 required positional argument: 'prefix'

Cause

The API response can include IP objects with a null value for the prefix field:

{
  "ips": [
    {
      "id": "<REDACTED>",
      "address": "<REDACTED>",
      "prefix": null,
      ...
    }
  ]
}

The unmarshal_Ip function seems to handle this case gracefully:

def unmarshal_Ip(data: Any) -> Ip:

However, the corresponding dataclass for Ip does not define prefix as optional:

Suggested Fix

Update the Ip dataclass to make prefix optional:

prefix: Optional[int] = None

This should resolve the TypeError when the field is null in the response.

Metadata

Metadata

Labels

instanceInstance issues, bugs and feature requestspriority:highestBugs filled by customers, security issues

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions