-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
16640 fix JSON custom field save nul #16713
Conversation
Hi all, I am the reported of the original issue. This PR appears to fix the issue for null values only. Editing existing values, or creating a prefix with a default value both lead to escaped strings being placed in the field |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further action is taken. |
@FliesLikeABrick could you please give instructions for reproducing a case which the PR does not address? |
Any non-null custom value is still corrupted via either of the instructions in the original problem report, such as : Option 2 - corruption on creation:
|
@FliesLikeABrick Can you please try the updated PR, I think it should fix the problem for newly created custom fields. It won't change those that are already have incorrect data. |
@arthanson @jeremystretch this PR appears to pass our tests for reproducing the issue, thank you |
Understood that this does not fix existing corrupt/damaged/impacted data - I have written a tool at https://github.com/FliesLikeABrick/netbox_fix_json which can be used to repair impacted data, for anyone else who comes across this. |
Any thoughts on when this will be merged? While we can ignore the human-readability aspect of it, it's becoming progressively more of a problem in some of our real-world uses. We've started having to write in bug-fix wrappers to integration code that reads these fields and recursively decode the values of all JSON fields to get the original data out. Luckily, it's not horrific to fix on the fly as you read it via API, but the longer this bug remains the more of an issue it will be in our object fields over time as people touch/edit objects. Thanks! |
100% agreed, we are having to add fixes to our tooling to catch bad json and repair it; and occasionally running the tool I published to go through and fix our fields of data altogether. |
@rbcollins123 @FliesLikeABrick please understand that NetBox is an extremely active project with very few people actually doing the work. For reference, we have had 73 PRs opened in the past 30 days, and each one of them consumes time. As a reminder, you always have the option of making changes locally yourself ahead of an official release if there's a truly pressing issue. |
Fixes: #16640
This will fix new saves, doesn't go back and fix old values - could set it to UI editable and edit it to fix. If you have saved multiple times then it will keep escaping so not sure if more dangerous to auto-fix with a validate as JSON and if not valid then revert to ''...
It looks like as it is UI_EDITABLE = FALSE the field isn't getting converted in clean as a JSON field, this works if UI_EDITABLE = True and the field is returned as a dict, if it is not UI editable the fields get returned as a string.