Skip to content

purefa_network: two AttributeError/TypeError regressions on interfaces without gateway or subinterfaces (1.44.0) #1029

Description

@dbuenoparedes

Describe the bug

Two crashes in purefa_network's update_interface() on freshly-provisioned interfaces, both instances of the pydantic model raising when a declared field is unset. Both hit after PR #1014 landed in everpure.flasharray 1.44.0. Under Mitogen they surface as Module result deserialization failed: No start of json char found.

Bug 1 — raw interface.eth.gateway access at line 383

if not module.params["gateway"] and interface.eth.gateway not in [
    None,
    IPNetwork(module.params["address"]),
]:

On an interface with no gateway configured (typical for iSCSI ports on a flat L2 SAN), interface.eth.gateway is None. The generated pydantic model raises AttributeError in that case rather than returning None (network_interface_eth_v_2_4.py:101). The current_state dict just above (lines 344-346) already reads gateway/address/netmask via getattr(interface.eth, ..., None) — line 383 is the one that was missed.

Traceback:

File ".../purefa_network.py", line 383, in update_interface
File ".../pypureclient/flasharray/_common/models/network_interface_eth_v_2_4.py", line 101, in __getattribute__
    raise AttributeError
AttributeError

Bug 2 — no or [] guard on interface.eth.subinterfaces

Two spots, both introduced/left by PR #1014:

  • Line 227 (_check_subinterfaces()): [0].eth.subinterfacesTypeError: 'NoneType' object is not iterable when the interface has no subinterfaces (plain physical ports).
  • Line 349 (current_state["subinterfaces"]): sorted(sub.name for sub in interface.eth.subinterfaces) — same failure mode.

interface.eth.subinterfaces is declared Optional[conlist(FixedReferenceNoId)] with default=None, so None is a legitimate value the SDK returns for interfaces without any children.

To Reproduce

  1. Install everpure.flasharray==1.44.0 with py-pure-client==1.88.0.
  2. Run purefa_network against any freshly-provisioned eth port that has no gateway or no subinterfaces — e.g. an iSCSI interface being brought up with address/mtu/servicelist but no gateway.

Expected behavior

Same as before the pydantic-strict schema landed: unset fields read as None, module treats them as such.

Suggested fix

Bug 1 — swap the raw access for getattr(..., None):

if not module.params["gateway"] and getattr(interface.eth, "gateway", None) not in [
    None,
    IPNetwork(module.params["address"]),
]:

Bug 2 — add or [] at both sites:

# _check_subinterfaces()
subinterfaces = list(
    array.get_network_interfaces(names=[module.params["name"]]).items
)[0].eth.subinterfaces or []
# update_interface() current_state
"subinterfaces": sorted(sub.name for sub in (interface.eth.subinterfaces or [])),

Happy to open a PR.

Environment

  • everpure.flasharray 1.44.0 · py-pure-client 1.88.0 · ansible-core 2.18 · Python 3.13 · Mitogen

Additional context

Follow-up to #1013 / PR #1014. The or [] gap was flagged during PR review; the line-383 issue is a distinct regression from the same eth-schema migration series (bcc1643, 083ce5c) that only got half-fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions