Surrounding quotes of JSON custom field's simple string default value lost when editing device #9559

Closed
opened 2025-12-29 21:18:58 +01:00 by adam · 3 comments
Owner

Originally created by @drustan on GitHub (Apr 30, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v3.7.6

Python Version

3.11

Steps to Reproduce

  • Add a custom field of type JSON (extras/custom-fields/add/)
    In the form use DCIM > Device as Content types, testing as name, JSON as type and "testing" (with the double quotes) as default value. Leave all the rest as it is and click create.
  • Navigate to a device page.
  • Click to edit the device.
  • Try to save without changing anything. An Error Enter a valid JSON will show up (the surrounding quotes of the JSON custom fields values are lost, you can't save unless adding the quotes around the value testing in the JSON custom fields)

Expected Behavior

When editing a device, surrounding quotes of JSON custom field values should be kept.

Observed Behavior

Surrounding quotes of already defined JSON custom field values are lost when editing a device.

Originally created by @drustan on GitHub (Apr 30, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v3.7.6 ### Python Version 3.11 ### Steps to Reproduce - Add a custom field of type JSON (extras/custom-fields/add/) In the form use **DCIM > Device** as Content types, **testing** as name, **JSON** as type and **"testing"** (with the double quotes) as default value. Leave all the rest as it is and click create. - Navigate to a device page. - Click to edit the device. - Try to save without changing anything. An Error **Enter a valid JSON** will show up (the surrounding quotes of the JSON custom fields values are lost, you can't save unless adding the quotes around the value **testing** in the JSON custom fields) ### Expected Behavior When editing a device, surrounding quotes of JSON custom field values should be kept. ### Observed Behavior Surrounding quotes of already defined JSON custom field values are lost when editing a device.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:18:58 +01:00
adam closed this issue 2025-12-29 21:18:58 +01:00
Author
Owner

@jeffgdotorg commented on GitHub (Apr 30, 2024):

Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v3.7.6 in my lab. Please re-confirm the reported behavior and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. The demo system's database has been through a lot and may be a factor in what you're experiencing, which is why the bug report template explicitly states that the demo system should not be relied on when reporting bugs.

@jeffgdotorg commented on GitHub (Apr 30, 2024): Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v3.7.6 in my lab. Please re-confirm the reported behavior and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a *clean installation* of NetBox to reproduce the issue. The demo system's database has been through a lot and may be a factor in what you're experiencing, which is why the [bug report template](https://github.com/netbox-community/netbox/issues/new?assignees=&labels=type%3A+bug%2Cstatus%3A+needs+triage&projects=&template=bug_report.yaml) explicitly states that the demo system should not be relied on when reporting bugs.
Author
Owner

@drustan commented on GitHub (Apr 30, 2024):

Hi, and thank you for your quick response. I've just updated the steps to reproduce the error. Forget about the demo instance then; I thought it would be easier since we both have access to it—sorry about that. The bug actually appeared recently; it was not present in version 3.5.X. Can you reproduce the bug now?

@drustan commented on GitHub (Apr 30, 2024): Hi, and thank you for your quick response. I've just updated the steps to reproduce the error. Forget about the demo instance then; I thought it would be easier since we both have access to it—sorry about that. The bug actually appeared recently; it was not present in version 3.5.X. Can you reproduce the bug now?
Author
Owner

@jeffgdotorg commented on GitHub (Apr 30, 2024):

Okay, the clarified steps got me there, thanks.

This problem seems to happen only when the field's default value is exactly a quoted string. If the default value is a list or associative array, the problem does not occur for me in 3.7.6.

I'm updating the summary and moving to needs owner.

@jeffgdotorg commented on GitHub (Apr 30, 2024): Okay, the clarified steps got me there, thanks. This problem seems to happen only when the field's default value is exactly a quoted string. If the default value is a list or associative array, the problem does not occur for me in 3.7.6. I'm updating the summary and moving to `needs owner`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9559