mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-11 21:10:29 +01:00
Get Environment Failure #5358
Closed
opened 2025-12-29 19:27:02 +01:00 by adam
·
28 comments
No Branch/Tag Specified
main
update-changelog-comments-docs
feature-removal-issue-type
20911-dropdown
20239-plugin-menu-classes-mutable-state
21097-graphql-id-lookups
feature
fix_module_substitution
20923-dcim-templates
20044-elevation-stuck-lightmode
feature-ip-prefix-link
v4.5-beta1-release
20068-import-moduletype-attrs
20766-fix-german-translation-code-literals
20378-del-script
7604-filter-modifiers-v3
circuit-swap
12318-case-insensitive-uniqueness
20637-improve-device-q-filter
20660-script-load
19724-graphql
20614-update-ruff
14884-script
02496-max-page
19720-macaddress-interface-generic-relation
19408-circuit-terminations-export-templates
20203-openapi-check
fix-19669-api-image-download
7604-filter-modifiers
19275-fixes-interface-bulk-edit
fix-17794-get_field_value_return_list
11507-show-aggregate-and-rir-on-api
9583-add_column_specific_search_field_to_tables
v4.5.0
v4.4.10
v4.4.9
v4.5.0-beta1
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.7
v4.4.0-beta1
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.9
v4.3.0-beta2
v4.2.8
v4.3.0-beta1
v4.2.7
v4.2.6
v4.2.5
v4.2.4
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.1.11
v4.1.10
v4.1.9
v4.1.8
v4.2-beta1
v4.1.7
v4.1.6
v4.1.5
v4.1.4
v4.1.3
v4.1.2
v4.1.1
v4.1.0
v4.0.11
v4.0.10
v4.0.9
v4.1-beta1
v4.0.8
v4.0.7
v4.0.6
v4.0.5
v4.0.3
v4.0.2
v4.0.1
v4.0.0
v3.7.8
v3.7.7
v4.0-beta2
v3.7.6
v3.7.5
v4.0-beta1
v3.7.4
v3.7.3
v3.7.2
v3.7.1
v3.7.0
v3.6.9
v3.6.8
v3.6.7
v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0.0
Labels
Clear labels
beta
breaking change
complexity: high
complexity: low
complexity: medium
needs milestone
netbox
pending closure
plugin candidate
pull-request
severity: high
severity: low
severity: medium
status: accepted
status: backlog
status: blocked
status: duplicate
status: needs owner
status: needs triage
status: revisions needed
status: under review
topic: GraphQL
topic: Internationalization
topic: OpenAPI
topic: UI/UX
topic: cabling
topic: event rules
topic: htmx navigation
topic: industrialization
topic: migrations
topic: plugins
topic: scripts
topic: templating
topic: testing
type: bug
type: deprecation
type: documentation
type: feature
type: housekeeping
type: translation
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/netbox#5358
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
Need to mention that "LLDP Neighbors" and "Configuration" works fine.
@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!@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_errorThank you
@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?
@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.
Thank you
@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:2Reponse Header:
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):
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
@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.
@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...
@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.
@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 iterablemessage.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
@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_environmentcalled 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 iterablemessage.Also, to answer @ktbyers 's question - I've had a look at the source code, and there's no logging for these errors:
That's the entire exception handler.
@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
@peshev commented on GitHub (Nov 20, 2021):
These are the devices I'm using:
They're all working with the
iosdriver@fskale commented on GitHub (Nov 20, 2021):
My patch is about the NXOS_SSH driver, as mentioned above. ;-)
@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?@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.@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:
In particular https://github.com/netbox-community/netbox/blob/v3.0.11/netbox/utilities/utils.py#L320
urllib.parse.unquote(k)will raiseTypeError: argument of type 'int' is not iterableOf 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:
@jeremystretch this should be reopen imho.
Thank you
@rizlas commented on GitHub (Dec 13, 2021):
Update: using optional parameter decode_keys to False with the same input.
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)
@ktbyers commented on GitHub (Dec 13, 2021):
@rizlas So the get environment works when you set this decode_keys=False in Netbox?
@rizlas commented on GitHub (Dec 13, 2021):
Yes, because with decode_keys to false
urllib.parse.unquote(k)is not triggered.@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?
@rizlas commented on GitHub (Dec 14, 2021):
I'll try to submit a PR for that.
@rizlas commented on GitHub (Dec 14, 2021):
@ktbyers Can you try it too?
@jeremystretch commented on GitHub (Dec 21, 2021):
Thanks @rizlas!
@rizlas commented on GitHub (Dec 21, 2021):
I'm a daily user of NetBox so thanks to you guys, looking forward for more collaboration.
@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.
@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
netboxusing 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!
@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.