500 when updating devices via PATCH /api/dcim/devices #11636

Closed
opened 2025-12-29 21:47:54 +01:00 by adam · 4 comments
Owner

Originally created by @PaulR282 on GitHub (Sep 19, 2025).

NetBox Edition

NetBox Community

NetBox Version

v.4.4.1

Python Version

3.12

Steps to Reproduce

Make an API PATCH call to /api/dcim/devices with a simple payload like:[{"id":XX,"position":null}]

Expected Behavior

The device should be saved with no position

Observed Behavior

The device does get saved with no position but the call returns a 500 with the following error:

TypeError at /api/dcim/devices/
'NoneType' object is not callable
Request Method:	PATCH
Request URL:	https://********/api/dcim/devices/
Django Version:	5.2.6
Exception Type:	TypeError
Exception Value:	
'NoneType' object is not callable
Exception Location:	/opt/netbox/netbox/extras/events.py, line 133, in process_event_rules
Raised during:	dcim.api.views.DeviceViewSet
Python Executable:	/opt/netbox-4.4.1/venv/bin/python3
Python Version:	3.12.3
Originally created by @PaulR282 on GitHub (Sep 19, 2025). ### NetBox Edition NetBox Community ### NetBox Version v.4.4.1 ### Python Version 3.12 ### Steps to Reproduce Make an API PATCH call to /api/dcim/devices with a simple payload like:`[{"id":XX,"position":null}]` ### Expected Behavior The device should be saved with no position ### Observed Behavior The device does get saved with no position but the call returns a 500 with the following error: ``` TypeError at /api/dcim/devices/ 'NoneType' object is not callable Request Method: PATCH Request URL: https://********/api/dcim/devices/ Django Version: 5.2.6 Exception Type: TypeError Exception Value: 'NoneType' object is not callable Exception Location: /opt/netbox/netbox/extras/events.py, line 133, in process_event_rules Raised during: dcim.api.views.DeviceViewSet Python Executable: /opt/netbox-4.4.1/venv/bin/python3 Python Version: 3.12.3 ```
adam added the type: bug label 2025-12-29 21:47:54 +01:00
adam closed this issue 2025-12-29 21:47:54 +01:00
Author
Owner

@jnovinger commented on GitHub (Sep 19, 2025):

@PaulR282 , thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.4.1. In my curl example below I'm working with demo data from netbox-communit/netbox-demo-data. Are you able to reproduce this bug with that data set? If not, then it seems like there is something different about your environment.

curl -X 'PATCH' \
  'http://127.0.0.1:8000/api/dcim/devices/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: 1RldFIOHsffiVZlypwvymmG5taco5mrDsYfELmUsaVUlP4xoSN5KJnO703V4njlx' \
  -H 'Authorization: Token abababababababababababababababababababab'
  -d '[{"id":34,"position":null}]'
[{"id":34,"url":"http://127.0.0.1:8000/api/dcim/devices/34/","display_url":"http://127.0.0.1:8000/dcim/devices/34/","display":"dmi01-albany-pdu01","name":"dmi01-albany-pdu01","device_type":{"id":8,"url":"http://127.0.0.1:8000/api/dcim/device-types/8/","display":"AP7901","manufacturer":{"id":11,"url":"http://127.0.0.1:8000/api/dcim/manufacturers/11/","display":"APC","name":"APC","slug":"apc","description":""},"model":"AP7901","slug":"ap7901","description":""},"role":{"id":5,"url":"http://127.0.0.1:8000/api/dcim/device-roles/5/","display":"PDU","name":"PDU","slug":"pdu","description":"","_depth":0},"tenant":{"id":5,"url":"http://127.0.0.1:8000/api/tenancy/tenants/5/","display":"Dunder-Mifflin, Inc.","name":"Dunder-Mifflin, Inc.","slug":"dunder-mifflin","description":""},"platform":null,"serial":"","asset_tag":null,"site":{"id":3,"url":"http://127.0.0.1:8000/api/dcim/sites/3/","display":"DM-Albany","name":"DM-Albany","slug":"dm-albany","description":""},"location":null,"rack":{"id":2,"url":"http://127.0.0.1:8000/api/dcim/racks/2/","display":"Comms closet","name":"Comms closet","description":""},"position":null,"face":{"value":"front","label":"Front"},"latitude":null,"longitude":null,"parent_device":null,"status":{"value":"active","label":"Active"},"airflow":null,"primary_ip":null,"primary_ip4":null,"primary_ip6":null,"oob_ip":null,"cluster":null,"virtual_chassis":null,"vc_position":null,"vc_priority":null,"description":"","comments":"","config_template":null,"config_context":{},"local_context_data":null,"tags":[{"id":20,"url":"http://127.0.0.1:8000/api/extras/tags/20/","display_url":"http://127.0.0.1:8000/extras/tags/20/","display":"Tango","name":"Tango","slug":"tango","color":"ff9800"},{"id":23,"url":"http://127.0.0.1:8000/api/extras/tags/23/","display_url":"http://127.0.0.1:8000/extras/tags/23/","display":"Whiskey","name":"Whiskey","slug":"whiskey","color":"c0c0c0"}],"custom_fields":{},"created":"2020-12-22T00:00:00Z","last_updated":"2025-09-19T14:44:20.991086Z","console_port_count":0,"console_server_port_count":0,"power_port_count":1,"power_outlet_count":8,"interface_count":20,"front_port_count":0,"rear_port_count":0,"device_bay_count":0,"module_bay_count":1,"inventory_item_count":0}]

Also, apologies for the accidental edit to the original report, that was a result of an internal tool that I used incorrectly.

@jnovinger commented on GitHub (Sep 19, 2025): @PaulR282 , thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.4.1. In my `curl` example below I'm working with demo data from [netbox-communit/netbox-demo-data](https://github.com/netbox-community/netbox-demo-data/). Are you able to reproduce this bug with that data set? If not, then it seems like there is something different about your environment. ```bash curl -X 'PATCH' \ 'http://127.0.0.1:8000/api/dcim/devices/' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: 1RldFIOHsffiVZlypwvymmG5taco5mrDsYfELmUsaVUlP4xoSN5KJnO703V4njlx' \ -H 'Authorization: Token abababababababababababababababababababab' -d '[{"id":34,"position":null}]' [{"id":34,"url":"http://127.0.0.1:8000/api/dcim/devices/34/","display_url":"http://127.0.0.1:8000/dcim/devices/34/","display":"dmi01-albany-pdu01","name":"dmi01-albany-pdu01","device_type":{"id":8,"url":"http://127.0.0.1:8000/api/dcim/device-types/8/","display":"AP7901","manufacturer":{"id":11,"url":"http://127.0.0.1:8000/api/dcim/manufacturers/11/","display":"APC","name":"APC","slug":"apc","description":""},"model":"AP7901","slug":"ap7901","description":""},"role":{"id":5,"url":"http://127.0.0.1:8000/api/dcim/device-roles/5/","display":"PDU","name":"PDU","slug":"pdu","description":"","_depth":0},"tenant":{"id":5,"url":"http://127.0.0.1:8000/api/tenancy/tenants/5/","display":"Dunder-Mifflin, Inc.","name":"Dunder-Mifflin, Inc.","slug":"dunder-mifflin","description":""},"platform":null,"serial":"","asset_tag":null,"site":{"id":3,"url":"http://127.0.0.1:8000/api/dcim/sites/3/","display":"DM-Albany","name":"DM-Albany","slug":"dm-albany","description":""},"location":null,"rack":{"id":2,"url":"http://127.0.0.1:8000/api/dcim/racks/2/","display":"Comms closet","name":"Comms closet","description":""},"position":null,"face":{"value":"front","label":"Front"},"latitude":null,"longitude":null,"parent_device":null,"status":{"value":"active","label":"Active"},"airflow":null,"primary_ip":null,"primary_ip4":null,"primary_ip6":null,"oob_ip":null,"cluster":null,"virtual_chassis":null,"vc_position":null,"vc_priority":null,"description":"","comments":"","config_template":null,"config_context":{},"local_context_data":null,"tags":[{"id":20,"url":"http://127.0.0.1:8000/api/extras/tags/20/","display_url":"http://127.0.0.1:8000/extras/tags/20/","display":"Tango","name":"Tango","slug":"tango","color":"ff9800"},{"id":23,"url":"http://127.0.0.1:8000/api/extras/tags/23/","display_url":"http://127.0.0.1:8000/extras/tags/23/","display":"Whiskey","name":"Whiskey","slug":"whiskey","color":"c0c0c0"}],"custom_fields":{},"created":"2020-12-22T00:00:00Z","last_updated":"2025-09-19T14:44:20.991086Z","console_port_count":0,"console_server_port_count":0,"power_port_count":1,"power_outlet_count":8,"interface_count":20,"front_port_count":0,"rear_port_count":0,"device_bay_count":0,"module_bay_count":1,"inventory_item_count":0}] ``` Also, apologies for the accidental edit to the original report, that was a result of an internal tool that I used incorrectly.
Author
Owner

@jeremystretch commented on GitHub (Sep 19, 2025):

Exception Location: /opt/netbox/netbox/extras/events.py, line 133, in process_event_rules

The error suggests you have an event rule trying to execute a missing/invalid custom script.

@jeremystretch commented on GitHub (Sep 19, 2025): > `Exception Location: /opt/netbox/netbox/extras/events.py, line 133, in process_event_rules` The error suggests you have an event rule trying to execute a missing/invalid custom script.
Author
Owner

@PaulR282 commented on GitHub (Sep 22, 2025):

@jnovinger @jeremystretch Sorry, my bad. There was a problem with a script triggered by an event rule when a device is updated. I don't think I would get a 500 if an event rule fails.

@PaulR282 commented on GitHub (Sep 22, 2025): @jnovinger @jeremystretch Sorry, my bad. There was a problem with a script triggered by an event rule when a device is updated. I don't think I would get a 500 if an event rule fails.
Author
Owner

@jnovinger commented on GitHub (Sep 22, 2025):

@PaulR282 , thanks for the update! If you happen to find an issue with the even rule logic that doesn't seem right (a 500 like you mentioned), we'd definitely like to hear about it.

@jnovinger commented on GitHub (Sep 22, 2025): @PaulR282 , thanks for the update! If you happen to find an issue with the even rule logic that doesn't seem right (a 500 like you mentioned), we'd definitely like to hear about it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11636