Skip to content

UI corrupts read-only JSON fields #16640

Closed
@FliesLikeABrick

Description

@FliesLikeABrick

Deployment Type

Self-hosted

NetBox Version

v4.0.5

Python Version

3.11

Steps to Reproduce

This issue can be reproduced in a couple different workflows. This was originally reported in #16328 after we saw this behavior, which we believe was introduced between 3.6.3 and 3.7.7. We have now reproduced this in a clean install of 4.0.5 running inside docker using netbox-docker 2.9.1.

Edits through the API are not impacted.

Option 1 - corruption during edit:

  1. Create a JSON custom field - set "UI Editable" to "No". Leave the default value as null.
  2. Create a prefix, it is not necessary to populate the JSON field with a value -- it will default to null
  3. View the prefix, observe that the JSON custom field shows a value of "-" in the UI due to it being null
  4. Edit the prefix and click "save" without making any changes
  5. Observe that the custom value now changes to the quoted string "null"

Option 2 - corruption on creation:

  1. Create a JSON custom field - set "UI Editable" to "No". Set the default to JSON such as {"key1":"value1"}
  2. Create a prefix
  3. View the prefix, observe that the JSON custom field now shows an escaped string value of "{\"key1\": \"value1\"}"
  4. Edit the prefix and click "save" without making any changes
  5. Observe that the custom value is now escaped again to something like "\"{\\\"key1\\\": \\\"value1\\\"}\""
  6. Repeat edit+save (without making changes) and observe that the prefix keeps getting escaped more and more as a JSON string instead of any valid JSON data structure.

Expected Behavior

The JSON value should not be changed due to the UI being set to read-only for this field

Observed Behavior

The server is setting a new and incorrect/corrupt value for this field in the database. The native JSON is being converted to an escaped string

Metadata

Metadata

Assignees

Labels

severity: mediumResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions