Skip to content

error when notifications is not defined - TypeError: NoneType object is not iterable #77

Description

@italovalcy

While using sdx-lib on FABRIC and there are L2VPN already created on SDX outside of FABRIC (witch does not have the notifications attribute), I'm getting the following error:

File /opt/conda/lib/python3.11/site-packages/sdxlib/sdx_client.py:343, in <listcomp>(.0)
    331     print("No L2VPNs found.")
    332     return None
    334 formatted = [
    335     {
    336         "Service ID": sid,
    337         "Name": l2vpn.name,
    338         "Endpoints": [
    339             {"port_id": endpoint.get("port_id", "Unknown"), "vlan": endpoint.get("vlan", "Unknown")}
    340             for endpoint in l2vpn.endpoints
    341         ],
    342         "Ownership": l2vpn.ownership,
--> 343         "Notifications": ", ".join(
    344             notification.get("email", "Unknown") if isinstance(notification, dict) else str(notification)
    345             for notification in l2vpn.notifications
    346         ),
    347         "Scheduling": str(l2vpn.scheduling or "None"),
    348         "QoS Metrics": str(l2vpn.qos_metrics or "None")
    349     }
    350     for sid, l2vpn in l2vpns.items()
    351 ]
    353 if format == "dataframe":
    354     return pd.DataFrame(formatted)

TypeError: 'NoneType' object is not iterable

This is happening because the default value for an optional attribute is being set to None:

value = data.get(key)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions