Skip to content

bug: Convert Query errors exporting IPs that are null #949

@jjeff07

Description

@jjeff07

Component

No response

Infrahub SDK version

1.19.0

Current Behavior

GQL:

Device {
    edges {
      node {
       __typename
        id
        ip {
          ip
        }
    }
}

Data:

{
  "data": {
    "Device": {
      "edges": [
        {
          "node": {
            "ip": {
              "ip": null
            }
        }
    }
}

Error:

File "C:\Users\justin.jeffery\Code\infrahub-avd\.venv\Lib\site-packages\infrahub_sdk\node\attribute.py", line 82, in __init__
    self._value = mapper(data.get("value"))
                  ~~~~~~^^^^^^^^^^^^^^^^^^^
  File "C:\Users\justin.jeffery\AppData\Local\Programs\Python\Python313\Lib\ipaddress.py", line 117, in ip_interface
    raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 interface')
ValueError: {'ip': None} does not appear to be an IPv4 or IPv6 interface

Expected Behavior

If an Attribute of kind IPHost is optional and has no value the GQL works fine with querying the value but if querying the ip instead it should also return None and not error. This means all my queries I either:

  • Cannot use converted response.
  • Or have to query the value, check if it is None, then manually split the mask off.

This may also apply to IPNetwork items as well.

Steps to Reproduce

  1. Create schema with IPHost Attribute
  2. Create Query extracting only the IP and not the value
  3. Use the converted resposne in the SDK

Additional Information

No response

Metadata

Metadata

Assignees

Labels

state/need-triageThis issue needs to be triagedtype/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions