Skip to content

TypeError: NoneType in sync_network_data_command_getter during tcp_ping connectivity check #547

@hectorruiz-tech

Description

@hectorruiz-tech

Environment

  • Python version: 3.12
  • Nautobot version: 2.x (Assumed based on UI screenshots)
  • nautobot-device-onboarding version: Latest/Current
  • ntc-templates version: 5.x

Expected Behavior

When running the "Sync Network Data From Network" job, the script should use the Port specified in the Job Form (e.g., 22) or default to 22 if the device record is empty. This should allow the tcp_ping connectivity check to succeed and proceed to run network commands.

Observed Behavior

The job fails immediately (duration ~1 second) with a TypeError. The logs show that task.host.port is being passed as None to the netutils.ping.tcp_ping function. Because int(None) is an invalid operation in Python, the job crashes.

File "/opt/nautobot/.../nautobot_device_onboarding/nornir_plays/command_getter.py", line 133, in netmiko_send_commands
    if not tcp_ping(task.host.hostname, task.host.port if task.host.port else 22):
  File "/usr/local/lib/python3.12/site-packages/netutils/ping.py", line 28, in tcp_ping
    sckt.connect((ip, int(port)))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Steps to Reproduce

  1. Select a device in Nautobot that has an IP address but has the TCP Port field left blank (null) in its device record.
  2. Run the job "Sync Network Data From Network".
  3. In the Job Form, enter 22 in the Port field (note: the bug persists even though this field is filled).
  4. Observe that the job fails with TypeError: ... not 'NoneType'.
  5. Note: Adding {"port": 22} to the device's Config Context does not resolve the issue, confirming the sync_network_data_command_getter function is not correctly mapping these variables to the Nornir inventory.

NTC-5581

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: 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