Updating object with JSON custom field causes a traceback
See original GitHub issueI have a JSON custom field on some objects in my NetBox 3.2beta instance. When trying to update one of the objects I get this traceback.
Traceback (most recent call last):
File "/home/jcollie/dev/netbox-maintenance/fix-model-aliases.py", line 602, in <module>
main()
File "/usr/lib/python3.10/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/home/jcollie/dev/netbox-maintenance/fix-model-aliases.py", line 597, in main
if device_type.save():
File "/home/jcollie/.local/lib/python3.10/site-packages/pynetbox/core/response.py", line 529, in save
updates = self.updates()
File "/home/jcollie/.local/lib/python3.10/site-packages/pynetbox/core/response.py", line 506, in updates
diff = self._diff()
File "/home/jcollie/.local/lib/python3.10/site-packages/pynetbox/core/response.py", line 484, in _diff
{fmt_dict(k, v) for k, v in self.serialize(init=True).items()}
File "/home/jcollie/.local/lib/python3.10/site-packages/pynetbox/core/response.py", line 457, in serialize
ret[i] = flatten_custom(current_val)
File "/home/jcollie/.local/lib/python3.10/site-packages/pynetbox/core/response.py", line 61, in flatten_custom
return {
File "/home/jcollie/.local/lib/python3.10/site-packages/pynetbox/core/response.py", line 62, in <dictcomp>
k: v if not isinstance(v, dict) else v["value"] for k, v in custom_dict.items()
KeyError: 'value'
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:12 (2 by maintainers)
Top Results From Across the Web
redmine - updating a list type custom field failed - Stack Overflow
I'm trying to update a list type custom field, with json like {'id': xx, "name": "xxxx", ... Traceback (most recent call last): File ......
Read more >Advanced field editing using JSON | Cloud automation Cloud
The JSON object can contain the attributes update or fields, for example: ... "My Text Customfield": "this is the same field as above...
Read more >Scripting Samples - Atlassian JIRA Plugins | Quisapps
root cause: Traceback (most recent call last): File ... Here is a Post Function I am using to update a custom field with...
Read more >jsonmerge - PyPI
As you can see, when encountering an JSON object, jsonmerge by default returns fields that appear in either base or head document. For...
Read more >traceback — Print or retrieve a stack traceback — Python 3.11 ...
Print up to limit stack trace entries from traceback object tb (starting from ... In particular, the __context__ field is calculated only if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @rodvand. I’ve tested the solution proposed above by markkuleinio and now everything works. Not sure if it may break something else, but up to the moment all other automations I’ve works fine.
It will be really nice if this can be included in pynetbox production release.
I’ve forked the repository and did a small change https://github.com/Kani999/pynetbox/tree/fix_cf_6.6.2
Then I released the forked version to pypi, so I can simply install it in my projects.
I’m trying to maintain the version with the original pynetbox, but I don’t guarantee anything in the future