Using just quotes in a device's local context data causes AttributeError #2482

Closed
opened 2025-12-29 18:19:15 +01:00 by adam · 1 comment
Owner

Originally created by @bdlamprecht on GitHub (Mar 25, 2019).

Environment

  • Python version: 3.6.7
  • NetBox version: 2.5.8

Steps to Reproduce

  1. Edit an existing device
  2. In the Local Config Context Data field, just add empty quotes (i.e. "")
  3. Click Update. No validation error is reported.
  4. When you then view the Config Context tab, the following error occurs:
The complete exception is provided below:
<class 'AttributeError'>

'str' object has no attribute 'items'

Technically, there is no reason to have just quotes in the Local Config Context Data (which is where I assume this error is originating from), there should either:

  1. Have a validation error when attempting to save the object
  2. Display None for bad or invalid data when viewed instead of raise an AttributeError

Expected Behavior

Explained above.

Observed Behavior

Explained above.

Originally created by @bdlamprecht on GitHub (Mar 25, 2019). ### Environment * Python version: 3.6.7 * NetBox version: 2.5.8 ### Steps to Reproduce 1. Edit an existing device 2. In the `Local Config Context Data` field, just add empty quotes (i.e. `""`) 3. Click `Update`. No validation error is reported. 4. When you then view the `Config Context` tab, the following error occurs: ``` The complete exception is provided below: <class 'AttributeError'> 'str' object has no attribute 'items' ``` Technically, there is no reason to have just quotes in the `Local Config Context Data` (which is where I assume this error is originating from), there should either: 1. Have a validation error when attempting to save the object 2. Display `None` for bad or invalid data when viewed instead of raise an `AttributeError` <!-- What did you expect to happen? --> ### Expected Behavior Explained above. <!-- What happened instead? --> ### Observed Behavior Explained above.
adam added the type: bugstatus: accepted labels 2025-12-29 18:19:15 +01:00
adam closed this issue 2025-12-29 18:19:15 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 28, 2019):

The JSON data is stored using django.contrib.postgres.fields.JSONField, so I'd rather avoid messing with input validation. I'll tweakget_config_context() to ignore empty data.

@jeremystretch commented on GitHub (Mar 28, 2019): The JSON data is stored using `django.contrib.postgres.fields.JSONField`, so I'd rather avoid messing with input validation. I'll tweak`get_config_context()` to ignore empty data.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2482