Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

name=iface['name'] - string indices must be integers #120

Open
Langlais115 opened this issue May 31, 2023 · 1 comment
Open

name=iface['name'] - string indices must be integers #120

Langlais115 opened this issue May 31, 2023 · 1 comment
Assignees
Labels
accepted This issue has been accepted for implementation bug Further discussion is needed to determine this issue's scope and/or implementation
Milestone

Comments

@Langlais115
Copy link
Contributor

I have an error when running a Full update

<class 'TypeError'>

string indices must be integers

Python version: 3.9.2
NetBox version: 3.5.1
2023-05-31 13:32:28,388 urllib3.connectionpool DEBUG: http://localhost:8001 "GET /api/dcim/interfaces/?device_id=3&name=eno16&limit=0 HTTP/1.1" 200 1174
2023-05-31 13:32:28,390 django.request ERROR: Internal Server Error: /plugins/proxbox/full_update/
Traceback (most recent call last):
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/views.py", line 93, in get
    "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]),
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 434, in all
    node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 392, in nodes
    full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 61, in node_full_update
    interfaces_updated = updates.node.interfaces(netbox_node, proxmox_json)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/updates/node.py", line 219, in interfaces
    ntb_iface = list(nb.dcim.interfaces.filter(device_id=netbox_node.id, name=iface['name']))
TypeError: string indices must be integers

If I execute the query using postman, I obtain this:

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 16,
            "url": "https://netbox/api/dcim/interfaces/16/",
            "display": "eno16",
            "device": {
                "id": 3,
                "url": "https://netbox/api/dcim/devices/3/",
                "display": "proxmox01 (CPFDKQ2)",
                "name": "proxmox01"
            },
            "vdcs": [],
            "module": null,
            "name": "eno16",
            "label": "",
            "type": {
                "value": "1000base-t",
                "label": "1000BASE-T (1GE)"
            },
            "enabled": true,
            "parent": null,
            "bridge": null,
            "lag": null,
            "mtu": 1500,
            "mac_address": "50:9A:4C:91:55:D8",
            "speed": null,
            "duplex": {
                "value": "full",
                "label": "Full"
            },
            "wwn": null,
            "mgmt_only": false,
            "description": "",
            "mode": null,
            "rf_role": null,
            "rf_channel": null,
            "poe_mode": null,
            "poe_type": null,
            "rf_channel_frequency": null,
            "rf_channel_width": null,
            "tx_power": null,
            "untagged_vlan": null,
            "tagged_vlans": [],
            "mark_connected": false,
            "cable": null,
            "cable_end": "",
            "wireless_link": null,
            "link_peers": [],
            "link_peers_type": null,
            "wireless_lans": [],
            "vrf": null,
            "l2vpn_termination": null,
            "connected_endpoints": null,
            "connected_endpoints_type": null,
            "connected_endpoints_reachable": null,
            "tags": [],
            "custom_fields": {},
            "created": "2023-05-31T13:27:56.412858Z",
            "last_updated": "2023-05-31T13:27:56.412922Z",
            "count_ipaddresses": 0,
            "count_fhrp_groups": 0,
            "_occupied": false
        }
    ]
}

As we can see the name of the interface is not an integer but a string, and as far as I'm concerned, it should be a string.

@emersonfelipesp emersonfelipesp self-assigned this May 31, 2023
@emersonfelipesp emersonfelipesp added bug Further discussion is needed to determine this issue's scope and/or implementation accepted This issue has been accepted for implementation labels May 31, 2023
@emersonfelipesp emersonfelipesp added this to the v0.0.6 milestone May 31, 2023
@emersonfelipesp
Copy link
Member

@Langlais115 I'm aware of this problem and want to fix all these data-types bugs and validation using FastAPI framework. I assigned this to v0.0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This issue has been accepted for implementation bug Further discussion is needed to determine this issue's scope and/or implementation
Projects
None yet
Development

No branches or pull requests

2 participants