Get Environment Failure #5358

Closed
opened 2025-12-29 19:27:02 +01:00 by adam · 28 comments
Owner

Originally created by @bogdancordos on GitHub (Sep 10, 2021).

Originally assigned to: @rizlas on GitHub.

NetBox version

v3.0.2

Python version

3.8

Steps to Reproduce

The issue occurs for all my devices (Cisco ISR4321 and WS-C3850) using NApalm Diver "ios".
I can't reproduce this on the demo instance, as it needs live devices with a primary IP.

1.Go to a device detail page
2.Click on "Status"

Expected Behavior

Both "Device Facts" and "Environment" to be populated.

Observed Behavior

Only the "Device Facts" gets populated, and no information seems to be pulled for "Environment".
Getting error:
image

Need to mention that "LLDP Neighbors" and "Configuration" works fine.

Originally created by @bogdancordos on GitHub (Sep 10, 2021). Originally assigned to: @rizlas on GitHub. ### NetBox version v3.0.2 ### Python version 3.8 ### Steps to Reproduce The issue occurs for all my devices (Cisco ISR4321 and WS-C3850) using NApalm Diver "ios". I can't reproduce this on the demo instance, as it needs live devices with a primary IP. 1.Go to a device detail page 2.Click on "Status" ### Expected Behavior Both "Device Facts" and "Environment" to be populated. ### Observed Behavior Only the "Device Facts" gets populated, and no information seems to be pulled for "Environment". Getting error: ![image](https://user-images.githubusercontent.com/57483807/132877275-9e6a162d-fd5e-4b87-a025-c393b23d0178.png) Need to mention that "LLDP Neighbors" and "Configuration" works fine.
adam added the type: bugstatus: accepted labels 2025-12-29 19:27:02 +01:00
adam closed this issue 2025-12-29 19:27:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 10, 2021):

Can you provide the raw data being returned from the device? You should be able to extract & replicate the underlying API request in the browser by hitting F12 to open the developer console, selecting the "Network" tab, and reloading the page. You should see an API call to /api/devices/xxx/napalm/. If you can copy the data from the response to that request we can look at where exactly the bug is occurring. Thanks!

@jeremystretch commented on GitHub (Sep 10, 2021): Can you provide the raw data being returned from the device? You should be able to extract & replicate the underlying API request in the browser by hitting F12 to open the developer console, selecting the "Network" tab, and reloading the page. You should see an API call to `/api/devices/xxx/napalm/`. If you can copy the data from the response to that request we can look at where exactly the bug is occurring. Thanks!
Author
Owner

@bogdancordos commented on GitHub (Sep 13, 2021):

The API returns as fallow:
{
"pageref": "page_1",
"startedDateTime": "2021-09-13T09:07:56.105+01:00",
"request": {
"bodySize": 0,
"method": "GET",
"url": "https://masked_server_name/api/dcim/devices/3/napalm/?method=get_facts&method=get_environment",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Host",
"value": "masked_server_name"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0"
},
{
"name": "Accept",
"value": "/"
},
{
"name": "Accept-Language",
"value": "en-GB,en;q=0.5"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br"
},
{
"name": "Referer",
"value": "https://masked_server_name/dcim/devices/3/status/"
},
{
"name": "x-csrftoken",
"value": "masked_token"
},
{
"name": "DNT",
"value": "1"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Cookie",
"value": "csrftoken=masked_token; sessionid=8a5bwq1rdueu1w4bhw52oan7ifmj7mo4"
},
{
"name": "Sec-Fetch-Dest",
"value": "empty"
},
{
"name": "Sec-Fetch-Mode",
"value": "cors"
},
{
"name": "Sec-Fetch-Site",
"value": "same-origin"
}
],
"cookies": [
{
"name": "csrftoken",
"value": "masked_token"
},
{
"name": "sessionid",
"value": "8a5bwq1rdueu1w4bhw52oan7ifmj7mo4"
}
],
"queryString": [
{
"name": "method",
"value": "get_facts"
},
{
"name": "method",
"value": "get_environment"
}
],
"headersSize": 659
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Server",
"value": "nginx/1.18.0 (Ubuntu)"
},
{
"name": "Date",
"value": "Mon, 13 Sep 2021 08:08:05 GMT"
},
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Content-Length",
"value": "581"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Vary",
"value": "Accept, Cookie, Origin"
},
{
"name": "Allow",
"value": "GET, HEAD, OPTIONS"
},
{
"name": "X-Content-Type-Options",
"value": "nosniff"
},
{
"name": "Referrer-Policy",
"value": "same-origin"
},
{
"name": "X-Frame-Options",
"value": "SAMEORIGIN"
}
],
"cookies": [],
"content": {
"mimeType": "application/json",
"size": 581,
"text": "{"get_facts":{"uptime":1745460,"vendor":"Cisco","os_version":"ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.5(3)S4b, RELEASE SOFTWARE (fc1)","serial_number":"masked_SN","model":"ISR4321/K9","hostname":"masked_hostanme","fqdn":"masked_hostanme.masked_domain","interface_list":["GigabitEthernet0/0/0","GigabitEthernet0/0/1","GigabitEthernet0","Virtual-Access1","Virtual-Access2","Vlan1"]},"get_environment":{"error":"Method get_environment failed: argument of type 'int' is not iterable"}}"
},
"redirectURL": "",
"headersSize": 313,
"bodySize": 894
},
"cache": {},
"timings": {
"blocked": 0,
"dns": 0,
"connect": 0,
"ssl": 0,
"send": 0,
"wait": 16301,
"receive": 0
},
"time": 16301,
"_securityState": "secure",
"serverIPAddress": "masked_server_ip",
"connection": "443"
}
]
}

I have saved the whole "Status" conversation on this file: 2341e4d0c5/netbox_env_error

Thank you

@bogdancordos commented on GitHub (Sep 13, 2021): The API returns as fallow: { "pageref": "page_1", "startedDateTime": "2021-09-13T09:07:56.105+01:00", "request": { "bodySize": 0, "method": "GET", "url": "https://masked_server_name/api/dcim/devices/3/napalm/?method=get_facts&method=get_environment", "httpVersion": "HTTP/1.1", "headers": [ { "name": "Host", "value": "masked_server_name" }, { "name": "User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0" }, { "name": "Accept", "value": "*/*" }, { "name": "Accept-Language", "value": "en-GB,en;q=0.5" }, { "name": "Accept-Encoding", "value": "gzip, deflate, br" }, { "name": "Referer", "value": "https://masked_server_name/dcim/devices/3/status/" }, { "name": "x-csrftoken", "value": "masked_token" }, { "name": "DNT", "value": "1" }, { "name": "Connection", "value": "keep-alive" }, { "name": "Cookie", "value": "csrftoken=masked_token; sessionid=8a5bwq1rdueu1w4bhw52oan7ifmj7mo4" }, { "name": "Sec-Fetch-Dest", "value": "empty" }, { "name": "Sec-Fetch-Mode", "value": "cors" }, { "name": "Sec-Fetch-Site", "value": "same-origin" } ], "cookies": [ { "name": "csrftoken", "value": "masked_token" }, { "name": "sessionid", "value": "8a5bwq1rdueu1w4bhw52oan7ifmj7mo4" } ], "queryString": [ { "name": "method", "value": "get_facts" }, { "name": "method", "value": "get_environment" } ], "headersSize": 659 }, "response": { "status": 200, "statusText": "OK", "httpVersion": "HTTP/1.1", "headers": [ { "name": "Server", "value": "nginx/1.18.0 (Ubuntu)" }, { "name": "Date", "value": "Mon, 13 Sep 2021 08:08:05 GMT" }, { "name": "Content-Type", "value": "application/json" }, { "name": "Content-Length", "value": "581" }, { "name": "Connection", "value": "keep-alive" }, { "name": "Vary", "value": "Accept, Cookie, Origin" }, { "name": "Allow", "value": "GET, HEAD, OPTIONS" }, { "name": "X-Content-Type-Options", "value": "nosniff" }, { "name": "Referrer-Policy", "value": "same-origin" }, { "name": "X-Frame-Options", "value": "SAMEORIGIN" } ], "cookies": [], "content": { "mimeType": "application/json", "size": 581, "text": "{\"get_facts\":{\"uptime\":1745460,\"vendor\":\"Cisco\",\"os_version\":\"ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.5(3)S4b, RELEASE SOFTWARE (fc1)\",\"serial_number\":\"masked_SN\",\"model\":\"ISR4321/K9\",\"hostname\":\"masked_hostanme\",\"fqdn\":\"masked_hostanme.masked_domain\",\"interface_list\":[\"GigabitEthernet0/0/0\",\"GigabitEthernet0/0/1\",\"GigabitEthernet0\",\"Virtual-Access1\",\"Virtual-Access2\",\"Vlan1\"]},\"get_environment\":{\"error\":\"Method get_environment failed: argument of type 'int' is not iterable\"}}" }, "redirectURL": "", "headersSize": 313, "bodySize": 894 }, "cache": {}, "timings": { "blocked": 0, "dns": 0, "connect": 0, "ssl": 0, "send": 0, "wait": 16301, "receive": 0 }, "time": 16301, "_securityState": "secure", "serverIPAddress": "masked_server_ip", "connection": "443" } ] } I have saved the whole "Status" conversation on this file: https://github.com/bogdancordos/netbox_scripts/blob/2341e4d0c5508b441cdcc9cb1e87396cdac2c827/netbox_env_error Thank you
Author
Owner

@jeremystretch commented on GitHub (Sep 13, 2021):

Looks like there's an error on the server side when processing the data being retrieved from the device. Can you enable debugging and get a complete stack trace when making the API call?

@jeremystretch commented on GitHub (Sep 13, 2021): Looks like there's an error on the server side when processing the data being retrieved from the device. Can you enable debugging and get a complete stack trace when making the API call?
Author
Owner

@bogdancordos commented on GitHub (Sep 13, 2021):

Not sure if this is the info requested:
I have enabled debug in configuration.py and this is the stack trace output.

tu/<	        https://masked_server/static/status.js:1:121908
Li/<	        https://masked_server/static/status.js:1:1233
Li		https://masked_server/static/status.js:1:1053
tu		https://masked_server/static/status.js:1:121739
Do/<	https://masked_server/static/status.js:2:106
Li/<	        https://masked_server/static/status.js:1:1233
Li		https://masked_server/static/status.js:1:1053
Do		https://masked_server/static/status.js:2:68
Ro		https://masked_server/static/status.js:2:5971
(Async: EventListener.handleEvent) 
<anonymous>	https://masked_server/static/status.js:2:6365
<anonymous>	https://masked_server/static/status.js:2:6407

Thank you

@bogdancordos commented on GitHub (Sep 13, 2021): Not sure if this is the info requested: I have enabled debug in configuration.py and this is the stack trace output. ``` tu/< https://masked_server/static/status.js:1:121908 Li/< https://masked_server/static/status.js:1:1233 Li https://masked_server/static/status.js:1:1053 tu https://masked_server/static/status.js:1:121739 Do/< https://masked_server/static/status.js:2:106 Li/< https://masked_server/static/status.js:1:1233 Li https://masked_server/static/status.js:1:1053 Do https://masked_server/static/status.js:2:68 Ro https://masked_server/static/status.js:2:5971 (Async: EventListener.handleEvent) <anonymous> https://masked_server/static/status.js:2:6365 <anonymous> https://masked_server/static/status.js:2:6407 ``` Thank you
Author
Owner

@fskale commented on GitHub (Sep 15, 2021):

I get the same.
I'm using the nxos_ssh driver. (netbox 3.0.1)
JSON answer: (without any errors)

{
  "get_environment" : {
    "cpu" : {
         "0" : {
            "%usage" : 78
         },
         "1" : {
            "%usage" : 26
         }
      },
      "fans" : {
         "invalid" : {
            "status" : true
         }
      },
      "memory" : {
         "available_ram" : 8253792,
         "used_ram" : 1903984
      },
      "power" : {
         "invalid" : {
            "capacity" : -1,
            "output" : -1,
            "status" : true
         }
      },
      "temperature" : {
         "Carmel-0-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 39
         },
         "Carmel-1-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 33
         },
         "Carmel-2-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 31
         },
         "Control-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 22
         },
         "Fan-side-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 22
         },
         "Intake-0-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 41
         },
         "Intake-1-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 49
         },
         "Outlet-1-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 52
         },
         "Port-side-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 38
         },
         "Sunnyvale-1" : {
            "is_alert" : false,
            "is_critical" : false,
            "temperature" : 38
         }
      }
   }
}

By querying the device, i get no errors, but…
The browser console clearly shows the error:

Uncaught (in promise) TypeError: right-hand side of 'in' should be an object, got undefined
    Nn https://netbox.example.domain/static/status.js:1
    so https://netbox.example.domain/static/status.js:2
    promise callback*so https://netbox.example.domain/static/status.js:2
    EventListener.handleEvent* https://netbox.example.domain/static/status.js:2
     https://netbox.example.domain/static/status.js:2

Reponse Header:

HTTP/2 200 OK
server: nginx
date: Wed, 15 Sep 2021 08:25:19 GMT
content-type: application/json
content-length: 951
vary: Accept, Cookie, Origin
allow: GET, HEAD, OPTIONS
x-content-type-options: nosniff
referrer-policy: same-origin
x-frame-options: SAMEORIGIN
server-timing: TimerPanel_utime;dur=1230.6889999999999;desc="User CPU time", TimerPanel_stime;dur=113.86499999999998;desc="System CPU time", TimerPanel_total;dur=1344.5539999999999;desc="Total CPU time", TimerPanel_total_time;dur=9629.544973373413;desc="Elapsed time", SQLPanel_sql_time;dur=21.278858184814453;desc="SQL 15 queries", CachePanel_total_time;dur=0;desc="Cache 0 Calls"
X-Firefox-Spdy: h2

An uncompressed version of status.js would be very helpful to debug !
Where can i obtain it ?

Best
Franz

@fskale commented on GitHub (Sep 15, 2021): I get the same. I'm using the nxos_ssh driver. (netbox 3.0.1) JSON answer: (without any errors) <pre> { "get_environment" : { "cpu" : { "0" : { "%usage" : 78 }, "1" : { "%usage" : 26 } }, "fans" : { "invalid" : { "status" : true } }, "memory" : { "available_ram" : 8253792, "used_ram" : 1903984 }, "power" : { "invalid" : { "capacity" : -1, "output" : -1, "status" : true } }, "temperature" : { "Carmel-0-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 39 }, "Carmel-1-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 33 }, "Carmel-2-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 31 }, "Control-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 22 }, "Fan-side-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 22 }, "Intake-0-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 41 }, "Intake-1-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 49 }, "Outlet-1-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 52 }, "Port-side-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 38 }, "Sunnyvale-1" : { "is_alert" : false, "is_critical" : false, "temperature" : 38 } } } } </pre> By querying the device, i get no errors, but… The browser console clearly shows the error: <pre> Uncaught (in promise) TypeError: right-hand side of 'in' should be an object, got undefined Nn https://netbox.example.domain/static/status.js:1 so https://netbox.example.domain/static/status.js:2 promise callback*so https://netbox.example.domain/static/status.js:2 EventListener.handleEvent* https://netbox.example.domain/static/status.js:2 <anonymous> https://netbox.example.domain/static/status.js:2 </pre> Reponse Header: <pre> HTTP/2 200 OK server: nginx date: Wed, 15 Sep 2021 08:25:19 GMT content-type: application/json content-length: 951 vary: Accept, Cookie, Origin allow: GET, HEAD, OPTIONS x-content-type-options: nosniff referrer-policy: same-origin x-frame-options: SAMEORIGIN server-timing: TimerPanel_utime;dur=1230.6889999999999;desc="User CPU time", TimerPanel_stime;dur=113.86499999999998;desc="System CPU time", TimerPanel_total;dur=1344.5539999999999;desc="Total CPU time", TimerPanel_total_time;dur=9629.544973373413;desc="Elapsed time", SQLPanel_sql_time;dur=21.278858184814453;desc="SQL 15 queries", CachePanel_total_time;dur=0;desc="Cache 0 Calls" X-Firefox-Spdy: h2 </pre> An uncompressed version of status.js would be very helpful to debug ! Where can i obtain it ? Best Franz
Author
Owner

@fskale commented on GitHub (Sep 15, 2021):

Update:
I updated to version 3.0.2.
After restarting all Services (nginx, netbox, netbox-rq) the error went away.
@bogdancordos
Take a look at the nginx logfiles.
Especially the error.log.

Best
Franz

@fskale commented on GitHub (Sep 15, 2021): Update: I updated to version 3.0.2. After restarting all Services (nginx, netbox, netbox-rq) the error went away. @bogdancordos Take a look at the nginx logfiles. Especially the error.log. Best Franz
Author
Owner

@bogdancordos commented on GitHub (Sep 16, 2021):

I have both NetBox and nginx up to date. I have restarted nginx, netbox, netbox-rq, but no errors are being thrown by nginx.
The "Method get_environment failed: argument of type 'int' is not iterable" is still present.
This is not critical and I can live with.

@bogdancordos commented on GitHub (Sep 16, 2021): I have both NetBox and nginx up to date. I have restarted nginx, netbox, netbox-rq, but no errors are being thrown by nginx. The "Method get_environment failed: argument of type 'int' is not iterable" is still present. This is not critical and I can live with.
Author
Owner

@fskale commented on GitHub (Sep 16, 2021):

@bogdancordos
The problem is not netbox.
It's the NAPALM driver itself.
I found a bug yesterday (nxos_ssh) and i'm sure you ran into the same problem.
As for the NXOS(SSH) driver, the parsing is very poor…
The output will not be trimmed which leads to an unexpected outcome.
I'll make a pull request today...

@fskale commented on GitHub (Sep 16, 2021): @bogdancordos The problem is not netbox. It's the NAPALM driver itself. I found a bug yesterday (nxos_ssh) and i'm sure you ran into the same problem. As for the NXOS(SSH) driver, the parsing is very poor… The output will not be trimmed which leads to an unexpected outcome. I'll make a pull request today...
Author
Owner

@jeremystretch commented on GitHub (Sep 16, 2021):

Thanks @fskale. I'm going to close this out as it seems to be related to the underlying NAPALM driver. But if anyone can point to a specific change that needs to be made to NetBox, please feel free to ask that it be reopened.

@jeremystretch commented on GitHub (Sep 16, 2021): Thanks @fskale. I'm going to close this out as it seems to be related to the underlying NAPALM driver. But if anyone can point to a specific change that needs to be made to NetBox, please feel free to ask that it be reopened.
Author
Owner

@ktbyers commented on GitHub (Nov 18, 2021):

@fskale Do you have some specifics? I have someone running into this, but they can't reproduce the issue outside of NetBox (i.e. get_environment()) call directly using NAPALM works, but fails with the:

Method get_environment failed: argument of type 'int' is not iterable message.

Also for the relevant person--how in NetBox can they get the full exception stack trace (instead of just the type message). I assume there is some logging they can enable or log file they can look at.

Thanks, Kirk

@ktbyers commented on GitHub (Nov 18, 2021): @fskale Do you have some specifics? I have someone running into this, but they can't reproduce the issue outside of NetBox (i.e. get_environment()) call directly using NAPALM works, but fails with the: `Method get_environment failed: argument of type 'int' is not iterable` message. Also for the relevant person--how in NetBox can they get the full exception stack trace (instead of just the type message). I assume there is some logging they can enable or log file they can look at. Thanks, Kirk
Author
Owner

@peshev commented on GitHub (Nov 20, 2021):

I'm running netbox built directly from github master, and I'm having the exact same problem as described by @ktbyers:
napalm --vendor ios --user $NAPALM_USERNAME --password $NAPALM_PASSWORD $NAPALM_HOST call get_environment
called within the netbox venv (in order to make sure it's the same napalm version that netbox is using) works fine - however, when it's called by netbox it fails with the
Method get_environment failed: argument of type 'int' is not iterable message.

Also, to answer @ktbyers 's question - I've had a look at the source code, and there's no logging for these errors:

            except Exception as e:
                response[method] = {'error': 'Method {} failed: {}'.format(method, e)}

That's the entire exception handler.

@peshev commented on GitHub (Nov 20, 2021): I'm running netbox built directly from github master, and I'm having the exact same problem as described by @ktbyers: `napalm --vendor ios --user $NAPALM_USERNAME --password $NAPALM_PASSWORD $NAPALM_HOST call get_environment` called within the netbox venv (in order to make sure it's the same napalm version that netbox is using) works fine - however, when it's called by netbox it fails with the `Method get_environment failed: argument of type 'int' is not iterable` message. Also, to answer @ktbyers 's question - I've had a look at the source code, and there's no logging for these errors: ``` except Exception as e: response[method] = {'error': 'Method {} failed: {}'.format(method, e)} ``` That's the entire exception handler.
Author
Owner

@fskale commented on GitHub (Nov 20, 2021):

I ended up rewriting a whole bunch of code, eliminating the '| json modifier' (the base OS if the N9K series is linux, so there's no json modifier ;-) ).
I will commit the changes next week and want you to try my changes before creating a PR.
What devices do you use, please name the exact types, it would help me a lot !
Stand by

@fskale commented on GitHub (Nov 20, 2021): I ended up rewriting a whole bunch of code, eliminating the '| json modifier' (the base OS if the N9K series is linux, so there's no json modifier ;-) ). I will commit the changes next week and want you to try my changes before creating a PR. What devices do you use, please name the exact types, it would help me a lot ! Stand by
Author
Owner

@peshev commented on GitHub (Nov 20, 2021):

These are the devices I'm using:

Manufacturer Model SKU Count
Cisco Catalyst 2960-24TT-L WS-C2960-24TT-L 4
Cisco Catalyst 2960-48TC-L WS-C2960-48TC-L 2
Cisco Catalyst 2960G-24TC- WS-C2960G-24TC-L 10
Cisco Catalyst 2960X-48TS- WS-C2960X-48TS-L 12
Cisco Catalyst 3750E-24TD WS-C3750E-24TD 1
Cisco Catalyst 3750E-48TD WS-C3750E-48TD 2
Cisco Catalyst 3750G-12S WS-C3750G-12S 1
Cisco Catalyst 3850-24S WS-C3850-24S 1
Cisco Catalyst 3850-24T WS-C3850-24T 1
Cisco Catalyst 3850-48T WS-C3850-48T 1

They're all working with the ios driver

@peshev commented on GitHub (Nov 20, 2021): These are the devices I'm using: |Manufacturer|Model|SKU|Count| |-----|--------------------|---------------|-| |Cisco|Catalyst 2960-24TT-L|WS-C2960-24TT-L|4| |Cisco|Catalyst 2960-48TC-L|WS-C2960-48TC-L|2| |Cisco|Catalyst 2960G-24TC-|WS-C2960G-24TC-L|10| |Cisco|Catalyst 2960X-48TS-|WS-C2960X-48TS-L|12| |Cisco|Catalyst 3750E-24TD|WS-C3750E-24TD|1| |Cisco|Catalyst 3750E-48TD|WS-C3750E-48TD|2| |Cisco|Catalyst 3750G-12S|WS-C3750G-12S|1| |Cisco|Catalyst 3850-24S|WS-C3850-24S|1| |Cisco|Catalyst 3850-24T|WS-C3850-24T|1| |Cisco|Catalyst 3850-48T|WS-C3850-48T|1| They're all working with the `ios` driver
Author
Owner

@fskale commented on GitHub (Nov 20, 2021):

My patch is about the NXOS_SSH driver, as mentioned above. ;-)

@fskale commented on GitHub (Nov 20, 2021): My patch is about the NXOS_SSH driver, as mentioned above. ;-)
Author
Owner

@ktbyers commented on GitHub (Nov 22, 2021):

The NX-OS pipe json issue is probably different than the "Method get_environment failed: argument of type 'int' is not iterable" error so if anyone has more details on that error (i.e. I full exception stack trace that is what I am looking for)?

@peshev And if you run get_environment() in NAPALM directly against your devices (i.e. outside of NetBox) you do not get an exception?

@ktbyers commented on GitHub (Nov 22, 2021): The NX-OS pipe json issue is probably different than the `"Method get_environment failed: argument of type 'int' is not iterable"` error so if anyone has more details on that error (i.e. I full exception stack trace that is what I am looking for)? @peshev And if you run `get_environment()` in NAPALM directly against your devices (i.e. outside of NetBox) you do not get an exception?
Author
Owner

@peshev commented on GitHub (Nov 23, 2021):

@ktbyers Yes, that is correct - when I run get_environment() directly in NAPALM, against the same device(s), I do not get an exception - it gets exectued successfully, and returns valid JSON output.

@peshev commented on GitHub (Nov 23, 2021): @ktbyers Yes, that is correct - when I run `get_environment()` directly in NAPALM, against the same device(s), I do not get an exception - it gets exectued successfully, and returns valid JSON output.
Author
Owner

@rizlas commented on GitHub (Dec 10, 2021):

This is still occurring in v3.0.11. I'm using the docker ones.

The bug is currently inside https://github.com/netbox-community/netbox/blob/v3.0.11/netbox/utilities/utils.py#L291 function.

Tested with a Cisco 2921, dict retrieved from the device:

{'cpu': {0: {'%usage': 2.0}}, 'memory': {'used_ram': 58955568, 'available_ram': 321187228}, 'temperature': {'invalid': {'is_alert': False, 'is_critical': False, 'temperature': -1.0}}, 'power': {'invalid': {'status': True, 'output': -1.0, 'capacity': -1.0}}, 'fans': {'invalid': {'status': True}}}

In particular https://github.com/netbox-community/netbox/blob/v3.0.11/netbox/utilities/utils.py#L320 urllib.parse.unquote(k) will raise TypeError: argument of type 'int' is not iterable

Of course removing that 0 key from the dict or change it to string "fix" the error but it is not a proper fix.

Full stack trace here:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-fa29b68bfd97> in <module>
----> 1 decode_dict(il_dict)

<ipython-input-4-7ac3d90c56a0> in decode_dict(encoded_dict, decode_keys)
     33         return {k: decode_value(v, decode_keys) for k, v in encoded_dict.items()}
     34 
---> 35     return {urllib.parse.unquote(k): decode_value(v, decode_keys) for k, v in encoded_dict.items()}
     36 

<ipython-input-4-7ac3d90c56a0> in <dictcomp>(.0)
     33         return {k: decode_value(v, decode_keys) for k, v in encoded_dict.items()}
     34 
---> 35     return {urllib.parse.unquote(k): decode_value(v, decode_keys) for k, v in encoded_dict.items()}
     36 

<ipython-input-4-7ac3d90c56a0> in decode_value(value, _decode_keys)
     26             if not _decode_keys:
     27                 return {k: decode_value(v, _decode_keys) for k, v in value.items()}
---> 28             return {urllib.parse.unquote(k): decode_value(v, _decode_keys) for k, v in value.items()}
     29         return value
     30 

<ipython-input-4-7ac3d90c56a0> in <dictcomp>(.0)
     26             if not _decode_keys:
     27                 return {k: decode_value(v, _decode_keys) for k, v in value.items()}
---> 28             return {urllib.parse.unquote(k): decode_value(v, _decode_keys) for k, v in value.items()}
     29         return value
     30 

/usr/lib/python3.9/urllib/parse.py in unquote(string, encoding, errors)
    654     if isinstance(string, bytes):
    655         return unquote_to_bytes(string).decode(encoding, errors)
--> 656     if '%' not in string:
    657         string.split
    658         return string

TypeError: argument of type 'int' is not iterable

@jeremystretch this should be reopen imho.

Thank you

@rizlas commented on GitHub (Dec 10, 2021): This is still occurring in v3.0.11. I'm using the docker ones. The bug is currently inside https://github.com/netbox-community/netbox/blob/v3.0.11/netbox/utilities/utils.py#L291 function. Tested with a Cisco 2921, dict retrieved from the device: ``` {'cpu': {0: {'%usage': 2.0}}, 'memory': {'used_ram': 58955568, 'available_ram': 321187228}, 'temperature': {'invalid': {'is_alert': False, 'is_critical': False, 'temperature': -1.0}}, 'power': {'invalid': {'status': True, 'output': -1.0, 'capacity': -1.0}}, 'fans': {'invalid': {'status': True}}} ``` In particular https://github.com/netbox-community/netbox/blob/v3.0.11/netbox/utilities/utils.py#L320 `urllib.parse.unquote(k)` will raise `TypeError: argument of type 'int' is not iterable` Of course removing that 0 key from the dict or change it to string "fix" the error but it is not a proper fix. Full stack trace here: ``` --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-12-fa29b68bfd97> in <module> ----> 1 decode_dict(il_dict) <ipython-input-4-7ac3d90c56a0> in decode_dict(encoded_dict, decode_keys) 33 return {k: decode_value(v, decode_keys) for k, v in encoded_dict.items()} 34 ---> 35 return {urllib.parse.unquote(k): decode_value(v, decode_keys) for k, v in encoded_dict.items()} 36 <ipython-input-4-7ac3d90c56a0> in <dictcomp>(.0) 33 return {k: decode_value(v, decode_keys) for k, v in encoded_dict.items()} 34 ---> 35 return {urllib.parse.unquote(k): decode_value(v, decode_keys) for k, v in encoded_dict.items()} 36 <ipython-input-4-7ac3d90c56a0> in decode_value(value, _decode_keys) 26 if not _decode_keys: 27 return {k: decode_value(v, _decode_keys) for k, v in value.items()} ---> 28 return {urllib.parse.unquote(k): decode_value(v, _decode_keys) for k, v in value.items()} 29 return value 30 <ipython-input-4-7ac3d90c56a0> in <dictcomp>(.0) 26 if not _decode_keys: 27 return {k: decode_value(v, _decode_keys) for k, v in value.items()} ---> 28 return {urllib.parse.unquote(k): decode_value(v, _decode_keys) for k, v in value.items()} 29 return value 30 /usr/lib/python3.9/urllib/parse.py in unquote(string, encoding, errors) 654 if isinstance(string, bytes): 655 return unquote_to_bytes(string).decode(encoding, errors) --> 656 if '%' not in string: 657 string.split 658 return string TypeError: argument of type 'int' is not iterable ``` @jeremystretch this should be reopen imho. Thank you
Author
Owner

@rizlas commented on GitHub (Dec 13, 2021):

Update: using optional parameter decode_keys to False with the same input.

In [7]: decode_dict(il_dict, decode_keys=False)
Out[7]: 
{'cpu': {0: {'%usage': 2.0}},
 'memory': {'used_ram': 58955568, 'available_ram': 321187228},
 'temperature': {'invalid': {'is_alert': False,
   'is_critical': False,
   'temperature': -1.0}},
 'power': {'invalid': {'status': True, 'output': -1.0, 'capacity': -1.0}},
 'fans': {'invalid': {'status': True}}}

Changing this:

https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/api/views.py#L504

to:

response[method] = decode_dict(getattr(d, method)(),decode_keys=False)

seems to fix the problem (for that input of course)

@rizlas commented on GitHub (Dec 13, 2021): Update: using optional parameter decode_keys to False with the same input. ``` In [7]: decode_dict(il_dict, decode_keys=False) Out[7]: {'cpu': {0: {'%usage': 2.0}}, 'memory': {'used_ram': 58955568, 'available_ram': 321187228}, 'temperature': {'invalid': {'is_alert': False, 'is_critical': False, 'temperature': -1.0}}, 'power': {'invalid': {'status': True, 'output': -1.0, 'capacity': -1.0}}, 'fans': {'invalid': {'status': True}}} ``` Changing this: https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/api/views.py#L504 to: `response[method] = decode_dict(getattr(d, method)(),decode_keys=False)` seems to fix the problem (for that input of course)
Author
Owner

@ktbyers commented on GitHub (Dec 13, 2021):

@rizlas So the get environment works when you set this decode_keys=False in Netbox?

@ktbyers commented on GitHub (Dec 13, 2021): @rizlas So the get environment works when you set this decode_keys=False in Netbox?
Author
Owner

@rizlas commented on GitHub (Dec 13, 2021):

Yes, because with decode_keys to false urllib.parse.unquote(k) is not triggered.

@rizlas commented on GitHub (Dec 13, 2021): Yes, because with decode_keys to false `urllib.parse.unquote(k)` is not triggered.
Author
Owner

@ktbyers commented on GitHub (Dec 13, 2021):

Okay, looks like a NetBox bug i.e. we are calling a URL string parser when we shouldn't be and NAPALM happens to have a string that contains a "%" in it so that causes this to fail. I only glanced at this quickly so if I misinterpreted this, let me know.

@jeremystretch Can we get this issue re-opened?

@ktbyers commented on GitHub (Dec 13, 2021): Okay, looks like a NetBox bug i.e. we are calling a URL string parser when we shouldn't be and NAPALM happens to have a string that contains a "%" in it so that causes this to fail. I only glanced at this quickly so if I misinterpreted this, let me know. @jeremystretch Can we get this issue re-opened?
Author
Owner

@rizlas commented on GitHub (Dec 14, 2021):

I'll try to submit a PR for that.

@rizlas commented on GitHub (Dec 14, 2021): I'll try to submit a PR for that.
Author
Owner

@rizlas commented on GitHub (Dec 14, 2021):

@ktbyers Can you try it too?

@rizlas commented on GitHub (Dec 14, 2021): @ktbyers Can you try it too?
Author
Owner

@jeremystretch commented on GitHub (Dec 21, 2021):

Thanks @rizlas!

@jeremystretch commented on GitHub (Dec 21, 2021): Thanks @rizlas!
Author
Owner

@rizlas commented on GitHub (Dec 21, 2021):

I'm a daily user of NetBox so thanks to you guys, looking forward for more collaboration.

@rizlas commented on GitHub (Dec 21, 2021): I'm a daily user of NetBox so thanks to you guys, looking forward for more collaboration.
Author
Owner

@ktbyers commented on GitHub (Dec 21, 2021):

Yes, thanks @rizlas I didn't have a good way to test this failure so I couldn't also test it.

@ktbyers commented on GitHub (Dec 21, 2021): Yes, thanks @rizlas I didn't have a good way to test this failure so I couldn't also test it.
Author
Owner

@Eschin commented on GitHub (Jan 11, 2022):

Hello,

Running Netbox 3.1.5 on Python 3.8.10.

We just upgraded from 3.1.2 to 3.1.5 across several instances of Netbox.

After upgrading, the Status, LLDP Neighbors, and Configuration tabs on devices are not pulling data successfully anymore. We receive the following error on all tabs; Error Fetching Device Config Error connecting to the device at 192.168.x.x: ConnectAuthError(192.168.x.x).

We do not have NAPALM_USERNAME or NAPALM_PASSWORD set in configuration.py, so it defaults to the system user netbox using ssh-keys to authenticate. We've had it working flawlessly this way for several years. We did try explicitly setting NAPALM_USERNAME, but still no success. Manually SSH'ing into devices via the backend CLI still works successfully.

This change is the only thing I noticed in change log related to our issue(since it touches on the NAPALM package), so wanted to see if they might be related. Thanks!

@Eschin commented on GitHub (Jan 11, 2022): Hello, Running Netbox 3.1.5 on Python 3.8.10. We just upgraded from 3.1.2 to 3.1.5 across several instances of Netbox. After upgrading, the Status, LLDP Neighbors, and Configuration tabs on devices are not pulling data successfully anymore. We receive the following error on all tabs; `Error Fetching Device Config Error connecting to the device at 192.168.x.x: ConnectAuthError(192.168.x.x)`. We do not have NAPALM_USERNAME or NAPALM_PASSWORD set in configuration.py, so it defaults to the system user `netbox` using ssh-keys to authenticate. We've had it working flawlessly this way for several years. We did try explicitly setting NAPALM_USERNAME, but still no success. Manually SSH'ing into devices via the backend CLI still works successfully. This change is the only thing I noticed in change log related to our issue(since it touches on the NAPALM package), so wanted to see if they might be related. Thanks!
Author
Owner

@DanSheps commented on GitHub (Jan 11, 2022):

This would be a separate discrete issue, please open another issue if you believe there are problems with Napalm.

@DanSheps commented on GitHub (Jan 11, 2022): This would be a separate discrete issue, please open another issue if you believe there are problems with Napalm.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5358