[BUG] Adding keywords throws an error: ValueError: invalid literal for int() with base 36: ''
Expected Behavior
When adding a keyword and clicking on "Save", the new keyword should be saved.
Actual Behavior
When adding a keyword like "planet_imagery" with a "planet_imagery" slug as a child of root, we get this error:
Request Method: POST
Request URL: https://server.ourserver.com/en-us/admin/base/hierarchicalkeyword/add/
Django Version: 4.2.17
Python Version: 3.10.12
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/admin/options.py", line 688, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/views/decorators/cache.py", line 62, in _wrapper_view_func
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/admin/sites.py", line 242, in inner
return view(request, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/admin/options.py", line 1886, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "/usr/local/lib/python3.10/dist-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/admin/options.py", line 1747, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/admin/options.py", line 1794, in _changeform_view
new_object = self.save_form(request, form, change=not add)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/admin/options.py", line 1221, in save_form
return form.save(commit=False)
File "/usr/local/lib/python3.10/dist-packages/treebeard/forms.py", line 147, in save
self.instance = self._meta.model.add_root(instance=self.instance)
File "/usr/local/lib/python3.10/dist-packages/treebeard/mp_tree.py", line 623, in add_root
return MP_AddRootHandler(cls, **kwargs).process()
File "/usr/local/lib/python3.10/dist-packages/treebeard/mp_tree.py", line 319, in process
return last_root.add_sibling('sorted-sibling', **self.kwargs)
File "/usr/local/lib/python3.10/dist-packages/treebeard/mp_tree.py", line 1106, in add_sibling
return MP_AddSiblingHandler(self, pos, **kwargs).process()
File "/usr/local/lib/python3.10/dist-packages/treebeard/mp_tree.py", line 425, in process
newpos = siblings.all()[0]._get_lastpos_in_path()
File "/usr/local/lib/python3.10/dist-packages/treebeard/mp_tree.py", line 1204, in _get_lastpos_in_path
return self._str2int(self.path[-self.steplen:])
File "/usr/local/lib/python3.10/dist-packages/treebeard/mp_tree.py", line 602, in _str2int
return cls.numconv_obj().str2int(num)
File "/usr/local/lib/python3.10/dist-packages/treebeard/numconv.py", line 97, in str2int
return int(num, radix)
Exception Type: ValueError at /en-us/admin/base/hierarchicalkeyword/add/
Exception Value: invalid literal for int() with base 36: ''
Steps to Reproduce the Problem
- Go to the admin panel > hierarchical keyword > Add hierarchical keyword
- Type in a name and a slug for instance, planet_imagery
- click "Save"
Specifications
- GeoNode version: 4.4.3
- Installation type (vanilla, geonode-project): geonode project
- Installation method (manual, docker): docker
- Platform: Redhat 9
- Additional details: Seems like the error has to do with the wrong arguments being passed to add_root(). Seems like a string is passed and not a model instance, like the doc on treebeard mention here.
Hi @lobenichou did you test it also in master branch? Anyway we will give a check
We tested the latest version (4.4.3) but we could check another or check out the master branch but I am hoping to have a stable version long term.
We tested the latest version (4.4.3) but we could check another or check out the master branch but I am hoping to have a stable version long term.
Hi @lobenichou the question about master is usually popped to understand if the issue was already fixed in the latest branch, so it makes easier (in case) to be backported to 4.4.x. You can also test it via the development demo available online
Hey @mattiagiupponi. Just tested adding a keyword to the metadata using the demo and it seems to work. I couldn't try it from the admin panel since I don't have acces to it. I can try on my dev branch to switch to master and test it out. Either way, I think that it seems to work properly in the master branch.
@mattiagiupponi just checking in on this. Since we're in prod, I'd rather use a stable release. If it could be backported, it'd be ideal. Thanks!
@lobenichou we're releasing 4.4.4 in a few days. If you or someone else could contribute a fix (there is also commercial support) for this we can include it in a new 4.4.5 release which, for the moment, is not planned.